Why are there errors in linking glpngd.lib with my C++ project?

naseeam used Ask the Experts™
My IDE is visual studio community 2019.  I'm  unable to link GLUT library with my C++ project.  I get following link errors:

link errors
Do I need to specify some windows libraries in "Additional Dependencies" field?

Additional Dependencies
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017

from the errors you are missing header files that define the functions mentioned in the error.
it tells you which files include the call to an undefined function or a define variable, structure, etc....
Top Expert 2016
the sscanf and __iob_func was provided by standard c library and thru header stdio.h.

the problem is that there are multiple versions of the standard library in visual studio depending on debug/release and the threading model (single-thrading, multiple threading). for 'normal' vs projects this was handled by msvcrt*.lib like

19/02/2018  20:30         3,270,618 msvcrt.lib
19/02/2018  20:30         3,721,526 msvcrtd.lib 

Open in new window

you could try to add msvcrtd.lib (d for debug) to the additional dependencies. but that might bring up new problems. if so, the recommended way is to look for an opengl packet which fits to your visual studio version.  

the missing __iob_func may come from the following macro definitions:

In visual studio 2015 for example stdin, stderr, stdout are defined as follow :

#define stdin  (__acrt_iob_func(0))
#define stdout (__acrt_iob_func(1))
#define stderr (__acrt_iob_func(2))

Open in new window

But previously, they were defined as:

#define stdin  (&__iob_func()[0])
#define stdout (&__iob_func()[1])
#define stderr (&__iob_func()[2])

Open in new window

so when you link against glpingd.lib which calls function __iob_func the default libs would provide __acrt_iob_func instead what doesn't match. the missing sscanf probably has some other reasons - i would assume a different threading model - but again i think, the opengl libraries don't fit to your project libraries.



Great solution, idea, and thought.  Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial