freeglut Linking error

Started by
4 comments, last by BitMaster 11 years, 4 months ago
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?
Advertisement
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.

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.
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.

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?
inquiry.png

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.
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).

This topic is closed to new replies.

Advertisement