glew32.lib linker error - opengl

I am writing a basic toon shader in OpenGL. I am using MSVC 2008. I have included the GLEW libraries. I have also set the additional dependencies in linker. But I am getting the following error:
LINK : fatal error LNK1104: cannot open file 'glew32.lib'

You need to set your linker to look in the correct place for the library. Either you don't have the lib, or your linker can't find it. Open your project properties dialog, go to linker, specify the lib as a dependency and provide the path to the correct lib folder.

you can also drag and drop the glew32.lib (or any other lib file of course) into your visual studio project and i think it will be automagically linked in and the linker will find it (which i think is your problem).
anyhow, i prefer setting my search directories by hand.

add this:
#pragma comment(linker, "/NODEFAULTLIB:libc.lib")
It will definitely solve your problem.

Related

Add obj file to linker input with cmake

I have a cmake project that needs to link to a library that contains some .lib files and a .obj file. I've found some clues to how to link to a .obj file, but most solutions seem very complex.
All I really want to do is tell cmake to add the .obj file to the linker input in my Visual Studio project.
I tried linking it as I am doing with normal lib files:
target_link_libraries(Foo C:/a.lib C:/b.lib C:/c.obj)
However when I check the linker input in the generated VS project, cmake has removed the full-path and appended .lib to the obj file:
C:/a.lib
C:/b.lib
c.obj.lib
What's the simplest way of getting this result:
C:/a.lib
C:/b.lib
C:/c.obj
Note that this only needs to work with Windows and Visual Studio.
I was facing facing the same issue when I found your question. It is solved by the following line:
SET_TARGET_PROPERTIES(my_project PROPERTIES LINK_FLAGS "/link setargv.obj")
The link is appended to Additional Options in the Command Line Section from project's linker settings.

cannot open file 'SDL2.lib'

I am trying to open sdl2 in my project on Visual C++ 2012 but i keep getting this error:
error LNK1104: cannot open file 'SDL2.lib'
I added the additional libraries and include folder but no luck..
I added the link to the libraries through the linker but i get the same error..
what should i do?
I'm referencing VS 2010, but I've read before that some people have had errors when using the VC++ Directories in their project properties as opposed to the Linker->General->Additional Library Directories.
Unfortunately, there really isn't much more to do besides making sure the directories are linked properly. There really is only one answer to this question. It also may depend on the download of SDL you chose, are you donwloading the Development Library as opposed to the binary?
Watch this video https://www.youtube.com/watch?v=or1dAmUO8k0.
In summary, you want to add the path include folder here: (configuration properties> C/C++ > General> Additional Include Directories),
and add the path of the lib folder here: (configuration properties> Linker > General> Additional Library Directories)
and finally, link .lib file in: linker > input > Additional Dependencies.
It seems like you didn't add your library directory path in VC++ Directories/Library Directories.. You have to link your library directory path (Where you have save you libraries of SDL) in your program. After adding, it will definitely work
I would like to add for others experiencing this problem that its an easy mistake if you are using the Development Library to link to the lib folder. SDL needs you link to either the x86 or x64 folder in the lib folder.
If you run or compile your program before you make those required changes of SDL then you will get this error always.. so first add a c++ file then make those changes and then write something and try to run ..this time it will never give this error
It seems like VS can't find the lib files. There are two ways you can do this. One is to configure the appropriate directories in VS as TwinkleBearDev's article shows. Another is to put the libraries directly where VS would look for them, as my article shows. I don't know if the folders for VS2012 are the same though - might be slightly different.

Dependency from .lib to another .lib

I'm trying to build OpenCV v2.3.1 using Intel TBB and IPP. I used CMake to generate Visual Studio 2010 solution. Build is successful and I have opencv_core231d.lib among output.
Now I'm trying to link opencv_core231d.lib with my project. However, after specifying it in Linker -> Additional dependencies, I receive error LNK1104: cannot open file 'tbb_debug.lib'.
That's not the error about unresolved externals. Linker wants specific .lib file from me! How can that be?
I've done dumpbin /all of opencv_core231d.lib and for several sections it tells me:
Linker Directives
-----------------
...
/DEFAULTLIB:"tbb_debug.lib"
...
I tried to add tbb_debug.lib to /NODEFAULTLIB linker option of my project and it solved the problem. However, I just want TBB to be linked in opencv_core231d.lib.
The strange thing is I cannot find any reason why tbb_debug.lib is added to /DEFAULTLIB option of opencv_core231d.lib. I've searched all files in solution directory mentioning tbb_debug.lib as a substring, but the only matches was in generated .obj and .lib files - not in any source or project files. Where is the magic?
This question is not only related to OpenCV, but to whole process of working with .lib-files.
Update
There was a #pragma comment(lib, "tbb_debug.lib") directive in TBB include file _tbb_windef.h, so now I can understand from where did it go.
What I still don't understand is why it is not statically linked in opencv_core231d.lib? I've set Librarian -> Link Library Dependencies option to Yes. And there are no #pragma comment(lib, "tbb_debug.lib") directives in my project - I've checked preprocessor output.
Thanks.
There's probably a #pragma comment(lib, "tbb_debug") somewhere in one of the header files you are including.
This is to do with using the thread building blocks by Intel. See this blog post for more information: http://software.intel.com/en-us/blogs/2008/07/07/get-tbb-going-by-a-single-click/

Linker library error in visual studio

Running visual studio 2010 writing an openGL program in C++
I'm getting this error, and can't for the life of me figure out why
fatal error LNK1104: cannot open file 'Image_Loading/nvImage.lib'
The file is in the correct place, and nvImage.lib is present in the additional dependencies of the linker, any ideas??
The folder "Image_Loading" is probably not in your library search path. Include files has a different search path, so even if its find the includes, the folder might be missing from the libary search path.
you should either add the folder to the LIB enviromental variable, or add /LIBPATH:folder to the command line of the linker.

Libtorrent library

I am using the boost for my application when I tried building using VIsual studio 9.0 i get
1>LINK : fatal error LNK1104: cannot open file 'libtorrent.lib'
how to make the libtorrent.lib . I am having trouble in this ....if any one is having any solution please help me.
The .lib is not included in your project. Make sure you are linking it in; Configuration Properties -> Linker -> Input -> Additional Dependencies
Another altnerative is to simply copy the .lib to your project folder but don't, it's bound to create problems later on.
Sometimes the .lib is not shipped with the library, so you need to compile it yourself. The README will tell you this. If this is the case, they usually ship with a .sln file you can open and the just compile it into a .lib file which you then reference in your main application, as I wrote above