• Welcome to Dark Bit Factory & Gravity.
 

Problems with Static lib using VC2009

Started by energy, May 24, 2010

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

energy

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

coding: jwasm,masm
hobby: www.scd2003.de

Clyde

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.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Jim

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
Challenge Trophies Won:

energy

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? 
coding: jwasm,masm
hobby: www.scd2003.de

energy

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???
:'( :'(
coding: jwasm,masm
hobby: www.scd2003.de

Jim

#5
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
Challenge Trophies Won:

energy

Jim:
Quote
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.


Quote
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?

coding: jwasm,masm
hobby: www.scd2003.de

Jim

You're right, for static libs it's:
Librarian (Bibliotekar)->General -> Ignore All Default Libraries

Jim
Challenge Trophies Won:

energy

linked with ignoring default lib,
no chance...
wants to have libcmt.lib with main  :'(
coding: jwasm,masm
hobby: www.scd2003.de

Jim

Challenge Trophies Won:

energy

same as before:
Quote
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
LibV2M.exe : fatal error LNK1120: 1 unresolved externals

coding: jwasm,masm
hobby: www.scd2003.de

Rbz

#11
Can you post your LIB file and masm test example for me to test?
Challenge Trophies Won:

energy

coding: jwasm,masm
hobby: www.scd2003.de

energy

Problem solved with help and a libcleaner tool
by Rbz.
Big thanks to him.... :-*
coding: jwasm,masm
hobby: www.scd2003.de