I was trying to install a neural networks toolbox called CarlSim using visual studio 2012, in which they use gtest in their code. I try to install gtest by downloading it online and build using gtest.sln file. It gives me two warnings. I guess these two warnings are the reason for this error. But I don't know how to solve this. The gtest seems only can build gtestd.lib.
Below is the error during install of the neural network toolbox
Error 2 error LNK1104: cannot open file 'gtest.lib' C:\Users\Dukerama\Desktop\CarlSim\carlsim\test\LINK carlsim_tests
Below are the warnings of the gest.
1>------ Rebuild All started: Project: gtest, Configuration: Debug Win32 ------
1> gtest-all.cc
1>C:\Program Files(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppBuild.targets(1299,5): warning MSB8012: TargetPath(C:\Users\Dukerama\Desktop\gtest\gtest- 1.6.0\msvc\gtest/Debug\gtest.lib) does not match the Library's OutputFile property value (C:\Users\Dukerama\Desktop\gtest\gtest-1.6.0\msvc\gtest\Debug\gtestd.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppBuild.targets(1301,5): warning MSB8012: TargetName(gtest) does not match the Library's OutputFile property value (gtestd). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1> gtest.vcxproj -> C:\Users\Dukerama\Desktop\gtest\gtest-1.6.0\msvc\gtest/Debug\gtest.lib
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Output from build command in VS you have posted suggests that there are inconsistencies between certain values in VS project properties for gtest (located in 'Configuration Properties -> General' and in 'Configuration Properties -> Librarian -> General'). However, output also suggests that the gtest library is built at location:
C:\Users\Dukerama\Desktop\gtest\gtest-1.6.0\msvc\gtest/Debug\gtest.lib
You should take this file and place it in directory where CarlSim toolbox expects to find the gtest library. You can find this out in the VS project properties for CarlSim ('Configuration Properties -> Linker -> General -> AdditionalLibraryDirectories').
P.S.
Make sure that both gtest and CarlSim link to the same runtime library, or you'll get more linker errors. You can inspect the runtime library in their VS project properties at 'Configuration Properties -> C/C++ -> Code Generation -> Runtime Library'.
I had the same problem.
Unfortunately, the proposed solution didn't help me.
In my case, the build worked properly on my PC, but it gave the error on a collegue's PC.
We solved it moving the project in a new location with a shorter path.
Related
I have successfully compiled my C++ program but I am a getting linker error
(default)\Catch2.lib(catch_stringref.cpp.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.cpp.obj
After reading the post I realized this is due to improper library selection by library (using release mode library while my application is in debug mode) hence I printed the path to catch2 library
CMake Code
find_library(CATCH2_LIBRARY catch2)
message ("CATCH2_LIBRARY : ${CATCH2_LIBRARY}")
target_link_libraries(${PROJECT_NAME} ${CATCH2_LIBRARY})
returned
CATCH2_LIBRARY : D:/vcpkg/installed/x64-windows/lib/Catch2.lib
instead of
D:/vcpkg/installed/x64-windows/debug/lib/Catch2d.lib
I wish to know how can I make the cmake look into the debug directory (for libraries) when I am building in debug mode and vice versa.
Kindly note in Debug Mode the library is Catch2d.lib and in release mode it is Catch2.lib.
Library Paths
Release Library Path : D:\vcpkg\installed\x64-windows\lib\Catch2.lib
Debug Library Path : D:\vcpkg\installed\x64-windows\debug\lib\Catch2d.lib
This is continuation of my first cmake usage saga carried forward from here
What you are most likely interested in, is something that's called a generator expression. This allows you to define specific flags/names/suffixes/prefixes etc. based on the specified configuration.
They usually look something like this:
target_link_libraries(foobar PRIVATE Catch2$<$<CONFIG:Debug>:d>)
When running cmake with the Debug configuration it will add a d at the end of Catch2
I recently started fixing some broken CMake-based build.
The project relies on a pre-built library (think .lib & .dll file).
The dependency is treated as an imported target; i.e. like this:
add_library(the_dependency SHARED IMPORTED GLOBAL)
set_target_properties(
the_dependency
PROPERTIES
IMPORTED_IMPLIB "definitely_correct_path/the_dependency.lib"
)
Building the project using the Visual Studio Generator works fine. However, using Ninja breaks the build leaving me with this error:
ninja: error: 'the_dependency.lib', needed by 'awesome/target', missing and no known rule to make it
Pretty much the same goes for NMake:
NMAKE : fatal error U1073: don't know how to make 'the_dependency.lib'
What I tried:
I defined the IMPORTED_LOCATION property additionally.
I checked the paths and they're definitely correct.
Also, peaking into the generated build files (i.e. build.ninja), it provides a rule for "generating" the DLL, but none for the LIB file.
Is there something I am missing?
Have a look at
-DENABLE_EXPORTS=TRUE
https://cmake.org/cmake/help/latest/prop_tgt/ENABLE_EXPORTS.html#prop_tgt:ENABLE_EXPORTS
I'm writing a simple Kotlin project as example of a my library's usage. The code is available on github. When I try to compile it, the compiler show me the following error:
I deleted build folders and .gradle directories, but nothing changes. Any ideas?
While building a new Rust "Project from other sources", in Intellij IDEA 2017, I was unable to run the project through its UI.
C:/Users/sjsui/.cargo/bin/cargo.exe run error: a bin target must be
available for cargo run
Process finished with exit code 101
I noticed that no --bin target was provided by my build configuration so I placed the path to the projects target folder; same result.
C:/Users/sjsui/.cargo/bin/cargo.exe run --bin C:\Users\sjsui\exercism\rust\hello-world\target\debug
error: no bin target named C:\Users\sjsui\exercism\rust\hello-world\target\debug
I tried creating a fresh Rust project through the Cargo command line interface, and received this error when running it:
error: could not exec the linker link.exe: The system cannot find the file specified. (os error 2)
note: the msvc targets depend on the msvc linker but link.exe was
not found
note: please ensure that VS 2013 or VS 2015 was installed with the
Visual C++ option
Evidently I must install Visual C++ build tools 2017 and am in the process of doing so. Are these errors related, or different issues?
By default, Cargo will consider the file src/main.rs to be the main binary target for the package. If this file doesn't exist, and there are no other binary targets defined in Cargo.toml, you'll get this error.
According to the documentation, when you create a Rust project in IntelliJ IDEA, you get an option to Use a binary (application) template. This should give you a src/main.rs instead of a src/lib.rs (which is the default root file for a library target). Using Cargo on the command line, you can also create an application package with cargo new hello.
Cargo defaults to --bin to make a binary program. To make a library, we'd pass --lib.
When you use --bin on the cargo run command, the argument refers to one of the [[bin]] sections in Cargo.toml, or files following the pattern src/bin/*.rs (the argument replaces the *) if there are no [[bin]] sections in Cargo.toml. For example, cargo run --bin foo will either compile and run src/bin/foo.rs or the [[bin]] section with name = "foo" in Cargo.toml.
i am trying to build box2D using cmake. When i click configure (and selecting my version of visual studio) cmake starts working but it finnishes with the error message:
You have called ADD_LIBRARY for library glfw without any source files.
This typically indicates a problem with your CMakeLists.txt file
Configuring done
What is the issue and how can i solve it? Where is the CMakeLists.txt located and how can i edit it to build without errors?
It is probably an error in this library. Try another version or post a bug.
It means that according to this file, a library should be created without source files (an empty library), which is probably bug.
CMakeLists.txt is located in every cmake source directory, make sure you're choosing the right directory.