A while ago I attempted to make make a game using c++ and SDL. I am now taking a class that requires me to program in C++ and I would like to use VS as the IDE. I uninstalled VS 2012 and upgraded to 2013. I am able to compile c# code but when I make a c++ project I get the error
error LNK1104: cannot open file 'SDL.lib'
I went to the project properties -> Configuration Properties -> Linker -> input and made sure that SDL was not referenced there. My Additional Dependencies now has the value %(AdditionalDependencies). The rest of the options are blank. I also made sure that in VC++ Directories the Include Directories did not include anything related to SDL. Having done all of this I still get the same error. Is is somehow inheriting the SDL linker. The project only contains a hello world program which does not include any other libraries. Any help is appreciated.
You can try this:
Right click the project and choose Properties.
Open Configuration Properties --> Linker -->Input.
In the Ignore Specific Default Libraries entry, add SDL.lib.
BTW, whatever you add in your Include Directories cannot cause a linkage error (and neither can any include that you have in your project).
Related
When I change either Linker, Input, Additional Dependencies, or VC++ Directories, the compiler behaves as though the changes did not happen.
That is, I can take all the additional dependencies out (though they are absolutely needed), and the project will still compile and link; or, if I don't initially put in the correct VC++ directories, adding those directories does not enable VS to find the files it needs. (If I right-click a #include , with its red squiggly lines showing there's a problem, it will say, SDL.h not found in... and list a slew of directories, none of which are the one I added.) This matters as I'm trying to determine which library is causing a conflict.
The IDE shows the changes I make when I reload Project Properties; it just won't act on them. It does notice if I change the Windows SDK Version.
This is only happening on one of my computers. I had recently installed Visual Studio 2019 Preview on it. Although I was running 2017, I still tried uninstalling 2019 Preview; no effect.
By request, here's a sample error message of not finding the include file:
c:\myProject\source\audiopath.cpp(14): fatal error C1083: Cannot open include file: 'audiopath.h': No such file or directory
And here's what I get if I try to load the include file by right-clicking #include:
File 'audiopath.h' not found in current source file's directory or in build system paths.
Current source file path: 'C:\myProject\source'
Build system path: [long list of directories, none of which are C:\myProject\include]
Here's what I have for Project Properties, VC++ Directories, Include Directories:
$(VC_IncludePath);$(WindowsSDK_IncludePath);c:\myProject\include
and Project Properties, C/C++, General, Additional Include Directories is c:\myProject\include.
c:\myProject\include does indeed contain audiopath.h.
This is typical case of editing properties of one configuration type (e.g. Release), and building another (e.g. Debug). In Visual Studio 2015 and 2017, when editing the project properties, always make sure that the selected configuration (Release/Debug) matches that of the one currently being edited.
I found this to be happening a lot at my workplace.
I've never used VS before.
My friend shared with me his program working and running correctly (she uses VS 2013 and I use 2017 - any compatibility problem?).
I've downloaded it and changed the paths on
Configuration Properties, C and C++, General, Additional Include Directories (picture below)
Configuration Properties, Linker, General, Additional Library Directories
However Im getting one fatal error which does not find this file located in:
Users\Julio\Documents\CPFL\SolverCPP\coin\libdebug
Users\Julio\Documents\CPFL\SolverCPP\coin\lib
How can I solve this path error? Also any tip to share project is welcome,
I am trying to extend my knowledge of constrain programming and I want to build a simple example using google's or-tools in VS2015.
However I am constantly nagged by those linker errors. LNK2019 and LNK2001. Why is linking in VS so darn hard.
Google's or-tools comes in a perfect folder, with an include subfolder and lib subfolder with one single .lib file.
I have added Additional Library Dependencies.
Configuration Properties -> Linker -> General Additional Library Dependencies : C:\PATH\or-tools.VisualStudio2013-64b\lib
Set the Input under the Linker properties section.
Configuration Properties -> Linker -> Input Additional Dependencies : ortools.lib
Infomed VC++ where the include directory is.
Configuration Properties -> VC++ Directories : C:\PATH\or-tools.VisualStudio2013-64b
However it is still throwing link errors when building the solution. What am I missing here.
Thanks in advance.
edit:
spelling
Since the VS2013 and VS2015 compiler versions are incompatible, you have to build the lib from source. Though beware that this might entail a bit more work when linking with VS2015. Specifically I've had to manually resolve the following issues:
Change protobuf-3.0.0-beta-1 to protobuf-3.0.0-beta-2(bonus. not really necessary)
gflags 2.1.2 failed to compile due to a conflict of names around snprintf. To resolve this download the latest gflags version from GitHub and overwrite the one in %OR_TOOLS%\dependencies
Look up all VS solution files (.sln) in dependencies\sources\cbc-2.9.7 and convert to VS2015 format by simply double clicking them and following the instructions.
Add the following code to makefiles\Makefile.port
ifeq ("$(VisualStudioVersion)", "14.0")
VISUAL_STUDIO=2015
VS_RELEASE=v140
VS_COMTOOLS=140
else
...
endif
Replace Visual Studio 12 2013 with Visual Studio 14 2015
Rerun make third_party after each step.
Or you can just download the end result, linked on Windows 10 x64 VS2015 update 1. I've included the whole folder after running make third_party && make cc.
Linking files is going to be the death of me.
So, I have had this problem many times before in both Visual Studio for C++ and Eclipse for Java. Right now I'm having problems in visual studio while trying to setup a project so I can start messing around with the Kinect SDK. The first thing I did was to include the NuiApi.h
#include <NuiApi.h>
I made sure to go into the VC++ directories and add the correct include directories $(KINECTSDK10_DIR)\inc and $(KINECTSDK10_DIR)\lib\x86 for the library directories. I also went to the Linker and added the Kinect10.lib in the additional dependencies in the Input section.
I still had the problem even after including these directories into the project. So I did some exploring and went to C/C++->General and added the include directories in the "Additional Include Directories" portion again just to see if that would fix it... that did nothing.
So I went back to the linker and added the library directories under General in Additional Library Directories to see if that would do anything and it still has not.
I'm at a complete loss right now and am so confused as to why these files aren't being included correctly! I swear this happens every time I try to work with a new API and I have to fiddle with it until it starts working for some reason. Am I doing something wrong? Am I missing something stupid? Does anyone have any ideas?
The difference between quoted and the angle-bracket form is explained here for visual studio. In principle, the quoted form is used for project specific includes, whereas the angle form is used for system libraries. In your case, the angle-bracket seems to be the right form.
What you have to do is to add the include to the C++ directories :
Right click on project -> Properties
VC++ directories
You should keep in mind that this setting is configuration-dependent, i.e. you have to do it for debug mode, but you'll have to repeat it for release mode.
Finally, you should make sure that the environment variable KINECTSDK10_DIR points to the right location (Windows+X -> System -> Advanced system parameters -> Environment variables). Attention: if you edit these parameters, you'll have to restart visual studio so that the new environment is taken into account.
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.