Skip to main content
GameDev.net gamedev.net
🔒 Locked

Link Error-Entry Point Must be defined

Started by marcus12 Oct 31, 2010 at 1:11 PM 9 replies 3.5k views
Original Post
marcus12
marcus12
Hi,
I am using MS visual studio 2008 and I created a solution with 2 projects
like:
Tackling(2 Projects)
|--> Game
|--> Engine


Game project has the void Main() as the entry point to the project and Engine project contain all the library files.


When i try to compile the project it gives link error like:
fatal error LNK1561: entry point must be defined

for the Engine files. The Game files compiles successfully.

I know that entry point is stating that it should have main() but Engine project does not need to have a main() as the Game already has it.

Let me know how to make the proper settings so that Engine files are properly linked.

All suggestions are welcome...

Indie Game Developer Game Studio: Freakout Games
smasherprog
smasherprog
are you compiling a windows program? If so, i bet you created an empty project! you need to set the compile option to Windows (/SUBSYSTEM:WINDOWS)
For ms 2008, goto tools->options->configuration properties->linker->System Select SubSystem and select Windows (/SUBSYSTEM:WINDOWS)
Wisdom is knowing when to shut up, so try it.
--Game Development http://nolimitsdesigns.com: Reliable UDP library, Threading library, Math Library, UI Library. Take a look, its all free.
adampetrone
adampetrone
It's also very likely that both projects are configured to be an executable, which
requires both to have a main (or WinMain).

It sounds like you want the Game to be the main executable and Engine to be the library. For the Engine project: in your Configuration Properties, under Project Defaults, change 'Configuration Type' to a Dynamic Library or Static Library.

From here, you'll have to properly setup exports on the Engine project and link to Engine.lib from your Game project.

Google for information regarding linking with static libraries for more information. Exporting from a DLL

Basically, you'll need to add __declspec(import) or __declspec(export) to classes and functions in your Engine project.
the_edd
the_edd
Quote:
Original post by marcus12
Game project has the void Main() as the entry point to the project and Engine project contain all the library files.


Ensure you have spelled it "main" in your code, with a lowercase 'm'. (It should also return int rather than void, though that shouldn't cause a linker error).
marcus12
marcus12
Quote:
Original post by adampetrone
It's also very likely that both projects are configured to be an executable, which
requires both to have a main (or WinMain).

It sounds like you want the Game to be the main executable and Engine to be the library. For the Engine project: in your Configuration Properties, under Project Defaults, change 'Configuration Type' to a Dynamic Library or Static Library.

From here, you'll have to properly setup exports on the Engine project and link to Engine.lib from your Game project.

Google for information regarding linking with static libraries for more information. Exporting from a DLL

Basically, you'll need to add __declspec(import) or __declspec(export) to classes and functions in your Engine project.


Hi,
After setting the Engine project: -> Configuration Properties, under Project Defaults, 'Configuration Type' to Static Library.

This solved the existing problem,but now when I try to access some function from
the Engine project by calling it in Game project it gives this error

error LNK2019: unresolved external symbol "void __cdecl .......

I have defined and declared all the functions in Engine files but still its giving the problem.

Is it because of that I need to link the Engine in some other way?
Indie Game Developer Game Studio: Freakout Games
mixmaster
mixmaster
Sounds like your not linking it into your executable at all or the engine (lib) uses more external libs your not linking in ?
Cheers Lee   Code is Life
C/C++, ObjC Programmer, 3D Artist, Media Production   Website : www.leestripp.com
Skype : lee.stripp@bigpond.com
Gmail : leestripp@gmail.com
marcus12
marcus12
Quote:
Original post by mixmaster
Sounds like your not linking it into your executable at all or the engine (lib) uses more external libs your not linking in ?


HI,
The Engine project contains at present for testing just a math file like YMath.h and YMath.cpp.
Engine project is configured as static library.


There is no .lib files been generated to link with Game project.

Then how it needs to be linked?
Indie Game Developer Game Studio: Freakout Games
marcus12
marcus12
Quote:
Original post by marcus12
Quote:
Original post by mixmaster
Sounds like your not linking it into your executable at all or the engine (lib) uses more external libs your not linking in ?


HI,
The Engine project contains at present for testing just a math file like YMath.h and YMath.cpp.
Engine project is configured as static library.


There is no .lib files been generated to link with Game project.

Then how it needs to be linked?


Hi,
Using nested namespace can be a problem for this ...I am using this type of nesting namespace


namespace YEngine
{
namespace Core
{
extern void foo();
}

}


This is in the YMath.h and then I define it in YMath.cpp

namespace YEngine
{
namespace Core
{
void foo()
{

std::cout << "Hello, world<< std::endl;

}
}
}


Then I try to call this in the Game project as YEngine::Core::foo();

then i get this link error.

what is causing this problem...how can i overcome it....?

Indie Game Developer Game Studio: Freakout Games
Evil Steve
Evil Steve
Quote:
Original post by marcus12
Engine project is configured as static library.

There is no .lib files been generated to link with Game project.
Then what is the output file? A static library project is a project that generates a .lib file. It's probably in your debug / release directory.
marcus12
marcus12
Quote:
Original post by Evil Steve
Quote:
Original post by marcus12
Engine project is configured as static library.

There is no .lib files been generated to link with Game project.
Then what is the output file? A static library project is a project that generates a .lib file. It's probably in your debug / release directory.


Hi,
Yeah it generated the .lib file. Now which is the place where I should place this .lib file so that it does not cause any path error when excuted in different systems.
Indie Game Developer Game Studio: Freakout Games
marcus12
marcus12
Quote:
Original post by marcus12
Quote:
Original post by Evil Steve
Quote:
Original post by marcus12
Engine project is configured as static library.

There is no .lib files been generated to link with Game project.
Then what is the output file? A static library project is a project that generates a .lib file. It's probably in your debug / release directory.


Hi,
Yeah it generated the .lib file. Now which is the place where I should place this .lib file so that it does not cause any path error when excuted in different systems.


Hi,
Got the solution...Thanks for all the suggestions :)
Indie Game Developer Game Studio: Freakout Games

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.