Jump to content

  • Log In with Google      Sign In   
  • Create Account


freeglut Linking error


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 black_darkness   Members   -  Reputation: 280

Like
0Likes
Like

Posted 10 December 2012 - 08:24 PM

Hello.

Here is what I am working with.
#include <stdlib.h>
#include <GL/freeglut.h>
int main()
{
return 0;
}

I am getting a linking error running this
fatal error LNK1120: 1 unresolved externals

This is what I am linking using additional dependencies.
freeglut.lib;

I guess what I am trying to ask is, What do I need to link to get freeglut to work?

Sponsor:

#2 BitMaster   Crossbones+   -  Reputation: 3918

Like
2Likes
Like

Posted 11 December 2012 - 01:40 AM

That error is unlikely to be the only one. There will be errors above there telling you exactly which symbols are unresolved. Without knowing the symbols you cannot even be sure the problem is freeglut, it could be a dependency of freeglut or something else entirely you are not linking. Or you could be using /SUBSYSTEM:Windows in which case you need to change that or define WinMain as the entry point.

#3 black_darkness   Members   -  Reputation: 280

Like
0Likes
Like

Posted 11 December 2012 - 08:15 AM

That error is unlikely to be the only one. There will be errors above there telling you exactly which symbols are unresolved. Without knowing the symbols you cannot even be sure the problem is freeglut, it could be a dependency of freeglut or something else entirely you are not linking. Or you could be using /SUBSYSTEM:Windows in which case you need to change that or define WinMain as the entry point.


Thank you. The problem was I created a win32 application, and not a win32 console application. I have no idea why this would matter though.

#4 BitMaster   Crossbones+   -  Reputation: 3918

Like
2Likes
Like

Posted 11 December 2012 - 10:14 AM

The entry function is the function which is called by the runtime to start the actual program after runtime initialization has finished. For /SUBSYSTEM:Console the common signatures are
int main();
int main(int, char**);
See the standard (or Wikipedia if a standard is not at hand) for a complete list of what is allowed here, although MSVC allows a few non-standard extensions.

For /SUBSYSTEM:Windows the entry function must be
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
Although it is possible to change the name of the entry function in MSVC, the signature still must be as expected.

#5 black_darkness   Members   -  Reputation: 280

Like
0Likes
Like

Posted 11 December 2012 - 09:11 PM

The entry function is the function which is called by the runtime to start the actual program after runtime initialization has finished. For /SUBSYSTEM:Console the common signatures are

int main();
int main(int, char**);
See the standard (or Wikipedia if a standard is not at hand) for a complete list of what is allowed here, although MSVC allows a few non-standard extensions.

For /SUBSYSTEM:Windows the entry function must be
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
Although it is possible to change the name of the entry function in MSVC, the signature still must be as expected.


Okay your telling me about /SUBSYSTEM:Console and /SUBSYSTEM:Windows.

Are these what you are reffering to?
Posted Image

If so I have another question.

I created a empty project both times. So I dont see how using the
int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
or using the
int main()
would have an effect.

I did use int main() {} both times. And on seperate projects using FLTK I used int main {} as the starting point on both empty win32 application and an empty win32 console application. However all I did was write the code in main.cpp. I didn't change any options aside from adding the neccessary links to the FLTK libs.

Thanks for the explanation I appreciate it.

#6 BitMaster   Crossbones+   -  Reputation: 3918

Like
0Likes
Like

Posted 12 December 2012 - 01:18 AM

I generally do not use the templates provided to create projects, so I cannot comment on their predefined settings. Even so, in MSVC 2008 the setting is simply accessible via Project Properties->Configuration Properties->Linker->System->SubSystem, so regardless of which template you have chosen, you can change that whenever the need arises.

Additionally, some libraries also come with an option to map the non-standard WinMain to a call to main (Qt and SFML both have an optional sublibrary to link for these cases).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS