Dark Bit Factory & Gravity
PROGRAMMING => C / C++ /C# => Topic started by: energy on May 24, 2010
-
Hi!
for me as non C++ Programmer, there is a small problem
with a static lib using vc2009.
I compiled the lib with VS2009 without precomiled header.
the Lib runs under Purebasic without problems,
but when i compile with MASM i get the following error:
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
LibV2M.exe : fatal error LNK1120: 1 unresolved externals
I think its an project options problem.
Anybody an idea???
Thanx in advance...
eNeRGy
-
I hope my knowledge of C adventures can help you with this dude.
There is probably something else that the library uses for the entry point, usually in a win32 program you'd use:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
//code in here.
}
if you go to the project settings in Linker - > Advanced, you should see Entry Point, in there needs to be what the library is using for it's main, for the tinptc lib it's crtMainStartup that needs to go in there.
-
The LIBCMT has code in it that looks like this
WinMainCrtStartup()
{
...
main(argc, argv);
}
The linker will automatically arrange for WinMainCrtStartup to be the entry point for your app. You can either override that in the linker, or you can have your asm code have an entry point that looks like
_main:
...
ret
Jim
-
Thanx Clyde,Jim for yur answers. :cheers:
I know to work with main as entrypoint, thats running fine.
but how can i deactivate in VC9.0 static lib project that this entrypoint will be ignored and that i can use any entrypoint?
-
Tried to link the static lib now on another PC
with an MASM Program where no Visual Studio is installed.
Now linker requires the libcmt.lib !
Where hell i can deaktivate to use libcmt.lib for building
the static lib in Visual Studio???
:'( :'(
-
In the linker options choose Ignore Default Libraries (I think the command line for this is /NODEFAULTLIB)
Then, as Clyde says:
if you go to the project settings in Linker - > Advanced, you should see Entry Point
Set it to
_main
I think the command line for this is /ENTRY:_main
Then make the entry point in your asm be
_main:
Jim
<edit> wrongly assumed you're trying to use libptc as well
-
Jim:
Set it to
_main
I think the command line for this is /ENTRY:_main
Then make the entry point in your asm be
_main:
Thats running well.
In the linker options choose Ignore Default Libraries (I think the command line for this is /NODEFAULTLIB)
Then, as Clyde says:
if you go to the project settings in Linker - > Advanced, you should see Entry Point
I cant find Linkersettings in my Project. Addapted a Picture.
Perhaps in case of the project is a static lib?
-
You're right, for static libs it's:
Librarian (Bibliotekar)->General -> Ignore All Default Libraries
Jim
-
linked with ignoring default lib,
no chance...
wants to have libcmt.lib with main :'(
-
What's the error message?
Jim
-
same as before:
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
LibV2M.exe : fatal error LNK1120: 1 unresolved externals
-
Can you post your LIB file and masm test example for me to test?
-
Rbz:
watch PM! :-*
-
Problem solved with help and a libcleaner tool
by Rbz.
Big thanks to him.... :-*