I built date_time library only and set up property page like this:
linker > input > additional dependencies:
libboost_date_time-vc120-mt-gd-1_55.lib boost_date_time-vc120-mt-gd-1_55.lib;%(AdditionalDependencies)
VC++ directories > library directories:
C:\boost_1_55_0\stage\lib;$(LibraryPath)
VC++ directories > include directories:
C:\boost_1_55_0;$(IncludePath)
when runing build I got following error:
1>LINK : fatal error LNK1104: cannot open file
'boost_date_time-vc120-mt-gd-1_55.lib.obj'
linker can't find the *.obj file, I can't find it either, where do need to look for *.obj file and what to do once I find it?
You shouldn't specify additional dependencies. Boost will auto link libraries using #pragma comment(lib, "<lib name>") when you include their headers. Try removing those explicit dependencies and rebuild.
Related
I am building a demo cross-platform application (Windows + Raspberry Pi) in C++. I am using vcpkg package manager for libraries.
When I create project only for Windows (without cmake) things work perfectly.
I am now trying to build for Windows using cmake I am getting the bellow mentioned error for libraries installed via vcpkg package manager. I have confirmed that libraies are installed and are working properly when used with normal Windows console application.
During installation of vcpkg the following line was returned to enable vcpkg support in cmake.
"-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
Cmake FIle
# Set to C++20 standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_BUILD_TYPE debug)
# Set to C17 standard
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED ON)
# Set vcpkg library path
set(CMAKE_TOOLCHAIN_FILE C:/vcpkg/scripts/buildsystems/vcpkg.cmake)
# Add source to this project's executable.
add_executable (Test main.cpp)
if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET Test PROPERTY CXX_STANDARD 20)
endif()
Error
fatal error C1083: Cannot open include file: 'boost/asio.hpp': No such file or directory
fatal error C1083: Cannot open include file: 'boost/asio.hpp': No such file or directory
fatal error C1083: Cannot open include file: 'mqtt/async_client.h': No such file or directory
fatal error C1083: Cannot open include file: 'plog/Log.h': No such file or directory
I am trying to build a java app with quarkus and graalvm. I am currently using graalvm version graalvm-ce-java11-windows-amd64-21.2.0 and updated the JAVA_HOME, GRAALVM_HOME and system path as well. For MSVC i have downloaded visual studio and selected the option of MSVC during the installation. BUt when I build the application using mvn clean package -Pnative I am getting below error message
Error: Error compiling query code (in C:\Users\sujay\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.c). Compiler command ''C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe' /WX /W4 /wd4244 /wd4245 /wd4800 /wd4804 /wd4214 '/FeC:\Users\sujay\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.exe' 'C:\Users\sujay\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.c'' output included error: [AMD64LibCHelperDirectives.c, C:\Users\sujay\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.c(1): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory]
com.oracle.svm.core.util.UserError$UserException: Error compiling query code (in C:\Users\sujay\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.c). Compiler command ''C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe' /WX /W4 /wd4244 /wd4245 /wd4800 /wd4804 /wd4214 '/FeC:\Users\sujay\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.exe' 'C:\Users\A740125\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.c'' output included error: [AMD64LibCHelperDirectives.c, C:\Users\A740125\AppData\Local\Temp\SVM-3930593782158447217\AMD64LibCHelperDirectives.c(1): fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory]
at com.oracle.svm.core.util.UserError.abort(UserError.java:139)
at com.oracle.svm.hosted.c.NativeLibraries.reportErrors(NativeLibraries.java:369)
at com.oracle.svm.hosted.NativeImageGenerator.processNativeLibraryImports(NativeImageGenerator.java:1616)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeLibraries(NativeImageGenerator.java:1090)
at com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:907)
at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:580)
at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$2(NativeImageGenerator.java:495)
at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1414)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:295)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
I dont know if the error is because of some version mismatch or wrong library. Please let me know if I am missing anything
This SO question seems to be about the same sort of issue, though not exactly. While I do not know if it will help, you may need to set another env variable pointing to the VC runtime
I am trying to utilize the ffmpeg libraries in a program of my own and am having trouble linking them. Specifically, In my a basic program I am receiving fatal error LNK1120: 1 unresolved externals errors. The program is:
#include <iostream>
#include <libswresample/swresample.h>
int main()
{
std::cout << "Hello World!\n";
struct SwrContext* swr_ctx = swr_alloc();
if (!swr_ctx) {
std::cout << "Could not allocate resampler context";
}
}
I downloaded prebuild libraries from https://ffmpeg.zeranoe.com/builds/, specifically the Windows x64 dev package which includes the .def/.lib as well as .dll files.
I originally tried (and intend to ultimately use) cmake to generate the MSVC sln files. The cmake file is:
cmake_minimum_required(VERSION 3.5)
project(ffmpeg_jni)
# Find the JNI bits
find_package(JNI)
# Search for the ffmpeg libraries
set(ffmpeg_include_hint "ffmpeg-dev/include")
set(ffmpeg_lib_hint "ffmpeg-dev/lib")
find_path(SWRESAMPLE_INCLUDE_DIR libswresample/swresample.h PATHS ${ffmpeg_include_hint})
find_library(SWRESAMPLE_LIBRARY swresample PATHS ${ffmpeg_lib_hint})
add_library(swresample SHARED IMPORTED)
set_target_properties(swresample PROPERTIES
IMPORTED_LOCATION "${SWRESAMPLE_LIBRARY}"
IMPORTED_IMPLIB "${SWRESAMPLE_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${SWRESAMPLE_INCLUDE_DIR}"
)
# Setup basic include dirs
set(includeDIRS
src/main/cpp
${JAVA_INCLUDE_PATH})
# Setup windows specific includes
set(includeDIRS
${includeDIRS}
${JAVA_INCLUDE_PATH}/Win32)
include_directories(${includeDIRS})
set(WRAPPER_SRC
src/main/cpp/logging.c
src/main/cpp/logging.h
src/main/cpp/main.cpp)
add_library(ffmpeg_jni SHARED ${WRAPPER_SRC})
target_link_libraries(ffmpeg_jni PRIVATE swresample)
The generated solution compiles and has proper access to the include files (Visual Studio can even take me to the declarations). The issue comes in the linking phase of the build where I receive:
error LNK2019: unresolved external symbol "struct SwrContext * __cdecl
swr_alloc(void)" (?swr_alloc##YAPEAUSwrContext##XZ) referenced in
function main
Thinking that I perhaps had something wrong in cmake since I am still pretty new with it I tried making a simple demo as a pure visual studio project following what I have found in countless online demos for adding an external library to a project. Specifically this included:
Adding the directory containing the header files to Properties->C/C++->General->Additional Include Directories
Adding the directory containing the .lib files to Properties->Linker->General->Additional Library Directories (Note that the cmake path did not do this but instead added the lib file via a relative path)
Adding the .lib file to Properties->Linker->Input->Additional Dependencies
At this point any searching efforts I undertake show me different people doing the same things which tells me I've been looking at this too long to find the answer myself and its something trivial that I'm missing/not understanding.
If you are compiling your project as c++, then include FFmpeg headers as below which tells your c++ compiler to handle FFmpeg headers as C instead of C++.
extern "C" {
#include <libswresample/swresample.h>
}
Under tools folder caffe library have some tools as single .cpp files
https://github.com/BVLC/caffe/tree/master/tools
I have added my own tool under this folder and can build it via cmake.
The problem that when I have added additional dependency (json lib jsoncpp) build fails at linking phase.
I have put json lib .h, .cpp files under tools/json folder.
My includes:
#include <iostream>
#include "opencv2/opencv.hpp"
#include "caffe/caffe.hpp"
#include "json/json.h"
Error that I get, like:
Undefined symbols for architecture x86_64:
"Json::StyledWriter::write(Json::Value const&)", referenced from:
image_list_processing(int, char**) in my_tool.cpp.o
So the question is how to add lib to linking process? Should I modify https://github.com/BVLC/caffe/blob/master/tools/CMakeLists.txt or maybe I should add separate file under tools/json/CMakeLists.txt?
This is not an error of missing .h file. You need to link your code to the shared object (libjsoncpp.so of similar) for your code to access (link) compiled json functions.
add -L /path/to/libjson_folder and -ljsoncpp flags to the linking stage of your makefile.
I downloaded and compiled CppUnit to compile with Visual Studio 2010.
After the conversion, I could load the CppUnitLibraries, and it gives me cppunit.lib and cppunit_dll.lib/dll. After copying the headers and libs to a directory, I run this command to get a lot of errors.
I found the conflict of libraries as follows
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library
However, the following command doesn't seem to work.
cl main.cpp complex.cpp testset.cpp /I"C:\CppUnit\include" /link /libpath:"C:\CppUnit\lib" cppunit.lib /NODEFAULTLIB:library
What's wrong with them?
This is the command that I used for compilation/link.
cl main.cpp complex.cpp testset.cpp /I"C:\CppUnit\include" /link /libpath:"C:\CppUnit\lib" cppunit.lib
This is the error message from VS2010.
cppunit.lib(TestResult.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL':
...
node###Z) already defined in LIBCMT.lib(typinfo.obj)
LINK : warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:lib
rary
main.exe : fatal error LNK1169: one or more multiply defined symbols found
ADDED
The CppUnit provides older version of project file (dsw), so I needed to convert the file to 2010 solution project manually.
For the error, missing /MD for compilation was the source of the problem. For other compilation warning, I needed to add /EHsc parameter.
cl /EHsc /MD /c /I"./CppUnit/include" main.cpp testset.cpp complex.cpp
link /libpath:"CppUnit/lib" main.obj testset.obj complex.obj cppunit.lib /out:cpptest_static.exe
link /libpath:"CppUnit/lib" main.obj testset.obj complex.obj cppunit_dll.lib /out:cpptest_dynamic.exe
seems like you compiled CppUnit in debug mode, weheras you're now compiling your current files in release mode. Those should not be mixed, and that's what the compiler is telling you.
The quickest way to resolve this would probably be to use a VS project, and check it's settings against the project used to compile CppUnit.
on your edit: you're also mixing runtime libraries (eg check that both are compiled using the /MD switch aka Multi-Threaded DLL)
I upgraded my CPPUNIT projects to visual studio 2010 and had to manually fix it.
The problem in the build was in the final actions where the output files are copied.
For the cppunit_dll project, one of the custom commands is:
copy "$(TargetPath)" ..\..\lib\$(TargetName).dll
copy "$(TargetDir)$(TargetName).lib" ..\..\lib\$(TargetName).lib
$(TargetName) is "cppunit_dll".
This conflicts with what we're actually building: if you look at the Linker options, you see that the output file name is "cppunitd_dll.dll".
The solution I used is to go to ConfigurationPropertys\General, and change "Target Name" from $(ProjectName) to"cppunitd_dll".
I had to to a similar solution for the cppunit project.
read INSTALL-VS.Net2008.txt in the cppunit folder after checking out the source code from SVN.
basically:
there is a visual studio solution under the examples folder.
that being said... i still can't get it to build without errors on vs2010 after converting it. i get 'cmd.exe' failed and failures to copy dlls.