C++ VS2010 no linker in project->properties - c++

I have problem with .lib files not found. I would like to check linker properties. However, in Project->Properties, I cannot find linker tab. What am i missing here ? Actually, I fear that I am not looking at project properties, but at properties for solution or whatever. What is a project exactly (which icon in VS for instance), or where can I look at project properties ?
Thanks !!

If there is no linker options, it is possible that the project is set to build a *.lib.
In this case you will be able to select 'Librarian' on the left of the project options. You can modify what the project is configured to build by going to General and then changing the Configuration type.
To get to the Project properties, right click on the project in the solution explorer window and click on properties.

It should be Project -> Properties(Alt+F7) -> Configuration properties -> Linker. Dependencies can be set in the Input tab under the Linker tab.

For clarification of the concept of "Projects" in Visual Studio:
The topmost node you see in the Solution Explorer (The panel which is (I believe) by default on the left of your window) is called the Solution. You can imagine it as a big bag to put everything related to solving a problem into.
This "everything" I'm talking about is put together using Projects. A project is essentially a bunch of code that is to be compiled into one distinct output file (a DLL/LIB, an application).
For instance, if you yourself were to write a library, you would create a solution encompassing all of it. Into the solution, you'd put the code of your library's components in separate projects. For testing, you'd add even more projects, each building an executable that is linking to your libraries.
For example:
---- MyLibrary (Solution)
|
+--- MyLibraryMath (Project)
|
+--- MyLibraryNetwork (Project)
|
+--- TestMath (Project, linking to MyLibraryMath)
|
+--- TestNetwork (Project, linking to MyLybraryNetwork)

Related

Visual Studio 2012 - error LNK1104: cannot open file 'glew32.lib'

I am having issues compiling a basic openGL program on VS 2012. I get a build error upon compiltation giving me:
1>LINK : fatal error LNK1104: cannot open file 'glew32.lib'
I followed the instructions given to me by the documentation for GLEW.
In your OpenGL project open Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> add glew32.lib.
Also you must include #include in your sources; For that add path to your glew folder: Project -> Properties -> Configuration Properies -> General -> VC++ Directories -> Include Directories and Library Directories;
C/C++ Tab -> General -> Additional Include Directories - Add lib folder there
I have also added the glew32.dll onto my Debug folder within my project folder along with the executable. So far I keep getting this error.
If you need any more further clarification of the steps I have done please don't hesitate to ask
In all honesty, there is no real benefit to using the DLL version of glew (short of reduced executable size, but this hardly matters on modern Windows PCs).
It is not like you can simply drop a new version of the DLL into your application and use extensions that you never used before. Likewise, bug fixes are so infrequent/unnecessary with a library that basically just parses the extension spec. files that using the DLL as a means of fixing extension loading bugs in shipped software is also not practical. Statically linking to glew (this means glew32s.lib) makes much more sense in the long run.
The static linking library is also more portable on Windows, it will work with MSVC and MinGW (whereas the DLL library only works with MSVC). Link against glew32s and put that in whatever directory you decided to use for additional library dependencies.
Here is a sample solution configuration for a project I wrote that uses glew. I have established a convention for this particular software where compile-time dependencies are stored under platform/<Subsystem>. Thus, I have glew32s.lib (32-bit) and glew64s.lib (64-bit) in ./Epsilon/platform/OpenGL/glew{32|64}s.lib
Steps to Use Classes form another project (Add header and solver linker errors)
To be able to add the header from another project, first go to "Properties > c++ > General > Additional Include Directories" and add the directory that contains the header. Now you will be able to add the header of the class from the other project, but running the project will still cause Linker Errors.
Add __declspec(dllexport) before the class you are using for the other project. This can be added in the header file of that class. This should be added right before the function or variable or class name. Now you will get a lib file. (if placed in wrong place, you can get this warning: https://msdn.microsoft.com/en-us/library/eehkcz60.aspx)
"Properties > Linker > Additional Library Directories". Specify the location of the lib file that is generated.
"Properties > Linker > Input > Additional Dependencies”: Add the name of the lib file.
This sounds like the library has been specified as a dependency, but the linker/additional search path(s) has not been set to include the directory where the library is located.
This may help.
It happened to me under this situation, I clean the solution and build it again, then many errors like LNK1104 occur.
After trying to restart IIS, I build solution successfully without LNK1104 errors. I do not know why, but restarting IIS takes much more time than normal, so I guess something is used by other IIS worker process.
Just give a shot to see if this magic happens on you.
This question is old and marked solved, but I had a similar problem symptoms with a completely different solution. So just in case anyone else stumbles in here:
It appeared that because I had 2 projects under one solution (a dll and an exe), the building order was mixed (from the output window):
1> Rebuilding project1..
2> Rebuilding project1..
1> file1.cpp
2> file1.cpp
and so on. By the message you copied, it appears you too have more than one project under one solution. One project was looking for the *.lib file that the other build hadn't created yet.
Solution:
Right click on "main" project -> Build Dependencies -> Project Dependencies.. -> Mark which project the main one depends on.

Netbeans / C++: Link 2 projects together (Executable / Dynamic Library)

I am creating 2 projects at the moment. The first one is an executable application. The second one is a Dynamic Library. Is there a way to link the Dynamic Library to the application in Netbeans so when I run the application I can load in the Dynamic Library. I know I could just copy the built files over, but that is a pain in the ass as I need to test if it's working every minute.
Does anyone know how to do this? I'm pretty sure it's possible as it would be so useful in many cases.
Yes it's possible:
Application Project -> right click -> Properties -> Linker
Libraries -> ... -> Add Project -> select your library project (-> check Build and select the Configuration if necessary)
Add the proper include directory at C or C++ Compiler settings
Properties -> Related Projects -> ... -> at your library project there
Not sure if step #4 is required.
If you build your application project, the library project will get build too.
An alternative is to point the project that uses the shared library to the directory where netbeans places the .so it generates from the shared library project. In other words, project 1 creates a shared library, project 2 uses it. So in netbeans right click on project2, choose
properties->linker->libraries (click "...")
then click on "add library" and navigate to the folder of project 1 that is the actual netbeans project folder -- in it there will be a "dist" directory, with children, something like "/dist/Debug/linux-x86/.so" choose that .so file
note, project 1 should be created as a netbeans "C Dynamic Library" project, in which case it will automatically pre-pend "lib" in front of the project name when it generates the .so, so that the .so file's name automatically starts with "lib"..
After that, you can update and build the two projects independently, and project 2 will always see the latest build of project 1.
Sean

How to make the visual studio 2008 IDE look at the right place for header files. Compiling Qt/C++ program

I am building an app on Qt 4.6.2 using visual studio 2008. I need to include the header <QtGui\QDir>.
Problem : The QDir header includes several headers. Once of them is qfile.h. Now the ide/compiler is unable to include this file and the error I get is this
c:\devprojects\myprojects\nttoolkit\trunk\external\qt\include\qtcore../../src/corelib/io/qfile.h(45)
: fatal error C1083: Cannot open
include file:
'Qt/include/QtCore/qiodevice.h': No
such file or directory
I cannot change the path in the file qfile.h since it is an external file to my project. How do I get it working.
Thanks.
The various places the preprocessor searches for include files is described in the Remarks section here.
Typically for an "SDK" like Qt people will change their VC++ Directories, Projects, Options under Tools | Options | "Projects and Solutions" | "VC++ Directories" so that the Include Files and Library Files lists include suitable Qt directories. That way, when the preprocessor searches for Qt include files, it will look in the right places and when the linker looks for .LIB files it will find them also.
One downside to changing those lists is that they apply to all projects built from that version of Visual Studio. That can be a pain in the neck if you have different projects that use different versions of an SDK. In those sorts of situations one solution is to create environment variables called INCLUDE and LIBPATH and then launch devenv with the /useenv switch to override the VC++ Directories settings from Tools | Options.
Finally, a third option is to provide the additional include and library folders via the project properties. In Project | Properties | C++ | General the first property is "Additional Include Directories". Values placed there are passed to the preprocessor via the /I switch. Similarly the Project | Properties | Linker | General tab has an "Additional Library Directories" property which gets passed to the linker via the /LIBPATH switch.
This third option seems attractive because it lets you set these additional directories on a project by project basis. The downside is that it "hard-codes" some directory names in the project. That can be a real pain if you move the project to a new machine where the Qt files are in a different directory or when you have to move the Qt directories to a different hard-drive, etc.
In VS2010, I go to:
Project Properties -> VC++ Directories -> Include Directories
And set the location of directories containing headers I need to include. I don't currently have access to a VS2008 install, but I think there is a similar configuration option available.

Link problem between projects in same solution (Exe depends on Lib)

I have one solution with several projects. Say ProjectA is the one that will produce the exe file, and ProjectB simply produces a .lib file. I have checked that ProjectA depends on ProjectB, so that ProjectB will always compile before ProjectA.
When I compile ProjectB everything goes fine. But if I compile ProjectA I get linking errors saying that some method of B does not exist. I have checked, and it does exist.
¿What is going on?
Thanks for your help!
Project Properties, Linker, General: Set "Link Library Dependencies" to Yes.
I found there were several things I needed to check to fix the vexing link error:
"link.exe" exited with code 1104.
As per #Eric's answer, on the top level (Project A) : Project -> Linker -> General -> Link Library Dependencies : Yes
Select the parent / top level project, and in the Project Properties prop list, click Project Depdendencies and ensure Project A references Project B
Somewhat counter intuitively, on ProjectA ensure that you don't have an additional linker library dependency on ProjectB.lib. This seems to encourage to look VS to look for another library called ProjectB.lib, elsewhere.
You do not need to add the output directory of ProjectB to ProjectA's additional Link directories (default is $(SolutionDir)$(Platform)\$(Configuration)\).

No Linker option in Visual Studio Project Properties

I'm trying to add a library to a Visual Studio C++ project, however, when I go to project properties I only have options for,
Common Properties
Startup Project
Project Dependencies
Debug Source File
Configuration Properites
Configuration
Why can't I see the linker options?
Updating answer for VS2012 to cover executable and libraries.
If your project is an executable then you need to navigate as such:
Myproject --> properties --> linker --> additional dependencies and add the dll or lib.
If you project is a library, there is no "linker" tab so you need to navigate as such:
Myproject -->properties --> Librarian --> additional dependencies and add the dll or lib
You are looking at the properties for the Solution.
You'll need to open the properties for the specific project within that solution.
Are you by any chance looking at a library project? Quoted from this answer:
A library is just a collection of objects, which by definition have not been linked yet. The linker is not used to create the library, so it makes sense that there would be no linker options for it.
In Visual Studio 2013:
Go to: Project Properties -> Configuration Manager -> General.
There, under Project Defaults, change the Configuration Type to either Dynamic Library or Application. Click on Apply. Then you should see the Linker tab added to the menu on the left.
If the Configuration Type (Configuration Properties -> General -> Configuration Type) is set to Utility, then no linker option will be available.
Either you are looking at the "solution" level or at a file level (e.g. main.cpp). Move to project level and you will see the Linker.