undefined main error

Feb 27, 2007 at 1:56am

undefined main error

trying to recompile the tutorial examples, using Visual Studio.NET and MAX/MSP 4.6, now gets an “undefined main” error in the Max Window. Building as a C++ project, compiling to .dll, renaming extension to .mxe, and placing it in Max search path.

Does anyone know where the mistake could be getting made? Thanks

#30479
Feb 27, 2007 at 2:04am

If I had to bet, I would place my money on C++ being the culprit. C++
mangles names of symbols in the dll. The dll loader is looking for
the main symbol but in your dll it’s probalby 34kjsnf823rbumain or
something equally wierd. What you need to do is link the main
function as well as any other static functions with C linkage. This
is pretty easy to do.

#ifdef __cplusplus
extern “C” {
#endif

main()

#ifdef __cplusplus
}
#endif

I’m not sure if __cplusplus is valid on the windows compiler. This
code does work for GCC. If it doesn’t work, you’ll need to find out
what the windows compiler flag is for detecting if C++ linkage is
being used.

HTH,
wes

On 2/26/07, Kieran Coulter wrote:
>
> trying to recompile the tutorial examples, using Visual Studio.NET and MAX/MSP 4.6, now gets an “undefined main” error in the Max Window. Building as a C++ project, compiling to .dll, renaming extension to .mxe, and placing it in Max search path.
>
> Does anyone know where the mistake could be getting made? Thanks
>

#97603
Feb 27, 2007 at 4:48am

maybe simply:

extern int main()
{
//… your code here
}

On Feb 26, 2007, at 6:04 PM, Wesley Smith wrote:

> If I had to bet, I would place my money on C++ being the culprit. C++
> mangles names of symbols in the dll. The dll loader is looking for
> the main symbol but in your dll it’s probalby 34kjsnf823rbumain or
> something equally wierd. What you need to do is link the main
> function as well as any other static functions with C linkage. This
> is pretty easy to do.
>
> #ifdef __cplusplus
> extern “C” {
> #endif
>
> main()
>
> #ifdef __cplusplus
> }
> #endif
>
>
> I’m not sure if __cplusplus is valid on the windows compiler. This
> code does work for GCC. If it doesn’t work, you’ll need to find out
> what the windows compiler flag is for detecting if C++ linkage is
> being used.
>
> HTH,
> wes
>
> On 2/26/07, Kieran Coulter wrote:
>>
>> trying to recompile the tutorial examples, using Visual Studio.NET
>> and MAX/MSP 4.6, now gets an “undefined main” error in the Max
>> Window. Building as a C++ project, compiling to .dll, renaming
>> extension to .mxe, and placing it in Max search path.
>>
>> Does anyone know where the mistake could be getting made? Thanks
>>

#97604
Feb 27, 2007 at 3:15pm

i’ve compiled externals using VC in c++ without having to specify any sort of extern statement. you also need to include a “.DEF” file that contains:
LIBRARY “WhateverTheNameIs”
EXPORTS main

#97605

You must be logged in to reply to this topic.