I want to include external libraries to my visual c++ Qt-add in project. Since my Qt project manager doesn't work I create a simple 'template' project with Qt-creator, and import the .pro file to Visual Studio via the add-in. I've added the commonly used libraries to the pro file in the creator, and with that I can build well, but in Visual Studio building gives me a linker error:
Error 2 error LNK1104: cannot open file 'OpenCL.lib' D:\Qt\Qt5.2.0\Tools\QtCreator\bin\qtpnds\LINK
The full .pro file I tried to import:
#-------------------------------------------------
#
# Project created by QtCreator 2013-12-28T17:27:01
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qtpnds
TEMPLATE = app
SOURCES += main.cpp\
mainwindowpnd.cpp
HEADERS += mainwindowpnd.h
FORMS += mainwindowpnd.ui
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lOpenCL
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lFreeImage
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lglew32
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
unix|win32: LIBS += -L$$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ -lglut32
INCLUDEPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
DEPENDPATH += $$PWD/C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/include
In creator I can use the library, it works well.
Using:
Qt 5.2.0 MSVC 2012 /w OpenGL.. OS: Windows 7 Ultimate SP1, x64.. Add-in version: Qt-VS-Add-In 1.2.2.. VS: Visual Studio 2012 Ultimate.
Is there any way to link libs in visual studio? #pragma comments and linking via project properties don't work, and I can't/don't know how to edit the .pro file in vs, without having to reimport it everytime I modify it.
I DID look for solutions, but I've only found posts about Qt-creator.
For those who might say use Qt-creator instead of addons, I won't.
Edit:
My opencl Lib is located in the C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/ folder, and its name is OpenCL.lib. (C:/Program Files (x86)/Microsoft Visual Studio 11.0/VC/lib/OpenCL.lib is the full path). The same for the other libraries. The files and libraries work in Qt-creator!
The libraries added to the addittional dependencies too.
OpenCL.lib
FreeImage.lib
...
Without the Qt Add-in the files link well, but after transforming a project to Qt, they cannot be opened. I tried also creating a new .pro file with the add-in.
Edit2:
After removing the libs from the additional dependencies, I get unresolved externals for all OpenCL functions. Changing the pro file library paths to:
-L"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib" -lOpenCL \
-L"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib" -lFreeImage
does't work too.
You will need to add all the necessary Qt libraries along with their path explicitly if the conversion does not take care of that, which is the case, I am afraid. You will also need to add the opencl library along with its path.
Make sure you do not mix the debug and release builds becaues that can go haywire in the Microsoft environment.
Here you can see the two dialog where you can basically assign these additional dependencies and libraries to the default.
Related
I'm using cmake to build the project.
There is a CMakeLists where is used to build the project.
So, when I create a build folder, and use
cmake ..
the project solution is created, but with MVSC c++ compiler.
Is it possible to generate a solution with GCC compiler but in a Visual studio solution?
How can I detect in CMakeLists.txt, that Visual Studio Clang toolset is used, as opposed to clang on Linux? When Visual Studio Clang toolset is used, I need to specify extra flags specific to Visual Studio headers (such as _CRT_SECURE_NO_WARNINGS).
Further info:
The toolset is Visual Studio Community 2019 Preview, version 16.10.0 Preview 3.0 (with C++ Clang Tools for Windows 10.0.0).
To build I am using Visual Studio Codium 1.56.2 with plugins CMake 0.0.17 and CMake Tools 1.7.2.
The VSCode CMake plugin autodetects Visual Studio Clang toolset, and when I select it, it builds with following command:
D:\dev_tools\cmake\bin\cmake.EXE --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE "-DCMAKE_C_COMPILER:FILEPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\Llvm\x64\bin\clang.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\Llvm\x64\bin\clang.exe" -Hd:/dev/exemine -Bd:/dev/exemine/build -G Ninja
The build works correctly. I just need to detect when this toolset is used from CMakeLists.txt and specify few extra options.
Note: As a workaround, I am using following code:
if(MSVC OR (CMAKE_CXX_COMPILER MATCHES "clang.exe$"))
add_compile_definitions(WIN32)
...
i have installed all dependencies as requires for Intel OpenVINO Toolkit.
as shown in guidelines of installation of OpenVINO toolkit for windows10.
https://docs.openvinotoolkit.org/latest/_docs_install_guides_installing_openvino_windows.html
after installation while running verification script i am getting this error.
C:\Program Files (x86)\IntelSWTools\openvino_2019.3.379\deployment_tools\demo>demo_squeezenet_download_convert_run.bat
Waiting for 0 seconds, press a key to continue ...
Creating Visual Studio 15 2017 x64 files in C:\Users\omiz\Documents\Intel\OpenVINO\inference_engine_samples_build...
CMake Error: Could not create named generator Visual Studio 15 2017
Generators
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files.
Optional [arch] can be "Win64" or "IA64".
Visual Studio 8 2005 [arch] = Generates Visual Studio 2005 project files.
Optional [arch] can be "Win64".
Visual Studio 7 .NET 2003 = Generates Visual Studio .NET 2003 project
files.
Visual Studio 7 = Deprecated. Generates Visual Studio .NET
2002 project files.
Visual Studio 6 = Deprecated. Generates Visual Studio 6
project files.
Borland Makefiles = Generates Borland makefiles.
NMake Makefiles = Generates NMake makefiles.
NMake Makefiles JOM = Generates JOM makefiles.
Green Hills MULTI = Generates Green Hills MULTI files
(experimental, work-in-progress).
MSYS Makefiles = Generates MSYS makefiles.
MinGW Makefiles = Generates a make file for use with
mingw32-make.
Unix Makefiles = Generates standard UNIX makefiles.
Ninja = Generates build.ninja files.
Watcom WMake = Generates Watcom WMake makefiles.
CodeBlocks - MinGW Makefiles = Generates CodeBlocks project files.
CodeBlocks - NMake Makefiles = Generates CodeBlocks project files.
CodeBlocks - Ninja = Generates CodeBlocks project files.
CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.
CodeLite - MinGW Makefiles = Generates CodeLite project files.
CodeLite - NMake Makefiles = Generates CodeLite project files.
CodeLite - Ninja = Generates CodeLite project files.
CodeLite - Unix Makefiles = Generates CodeLite project files.
Eclipse CDT4 - MinGW Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - NMake Makefiles
= Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Ninja = Generates Eclipse CDT 4.0 project files.
Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.
Kate - MinGW Makefiles = Generates Kate project files.
Kate - NMake Makefiles = Generates Kate project files.
Kate - Ninja = Generates Kate project files.
Kate - Unix Makefiles = Generates Kate project files.
Sublime Text 2 - MinGW Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - NMake Makefiles
= Generates Sublime Text 2 project files.
Sublime Text 2 - Ninja = Generates Sublime Text 2 project files.
Sublime Text 2 - Unix Makefiles
= Generates Sublime Text 2 project files.
Error
Today I ask myself if it's possible to convert/upgrade an Visual Studio 2011/12 makefile.mak into a Visual Studio 2017 Enterprise file/version?
Maybe it's neccessary to create it from scratch or an empty template but I am not sure.
Here is what I got already:
# Microsoft specific Programms/Configs
CC = cl
LINK = link
LIB = lib
INCLPATH= "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE"
COMPOPT = -I$(INCLPATH) -c
LINKOPT = /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\DIA SDK\lib" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.13.26128\lib" //Path?
LIBOUT = /OUT:
#Targets
all: exercise9_4.exe clean
exercise9_4.exe: exercise9_4.obj customer.lib
$(LINK) $(LINKOPT) uebung9_4.obj customer.lib
exercise9_4.obj: exercise9_4.c
$(CC) $(COMPOPT) exercise9_4.c
customer.lib: customer.obj
$(LIB) $(LINKOPT) customer.obj
customer.obj: customer.c customer.h
$(CC) $(COMPOPT) customer.c customer.h
clean:
del exercise9_4.obj
del customer.lib
del customer.obj
Question which paths do I need in VisualStudio 2017?
Did the commands change?
I would really appriciate your help. :D
Because VS2017 reclaims an Upgrade is not possible.
Easy Solution:
Remove Paths, Blank Spaces, insert correct paths(link, cl, lib)
Open it in Visual Studio 2015 Dev-Console,
put in "nmake makefile.mak" -> hit enter, wait a few seconds,
it works :D
Currently, in order to create static libs on windows, you manually have to specify where the Visual Studio directory is.
cmake -G "MinGW Makefiles" -DCMAKE_C_COMPILER=gcc -DCMAKE_GNUtoMS=1 -DCMAKE_GNUtoMS_VCVARS="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" ..
Is there a way for CMake to automatically query for the location of Visual Studio? The Windows-GNU.cmake module seems to be able to query the registry for the location of the lib.exe executable, but still forces the user to manually specify it's location. An excerpt from cmake:
find_program(CMAKE_GNUtoMS_VCVARS NAMES vcvars32.bat
DOC "Visual Studio vcvars32.bat"
PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\12.0\\Setup\\VC;ProductDir]/bin" #D
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\11.0\\Setup\\VC;ProductDir]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC;ProductDir]/bin"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++;ProductDir]/bin"
)
The above is from cmake 3.6.0.
If building a static library is your primary concern, have you tried setting
-DBUILD_SHARED_LIBS=OFF
or similar (e.g. add_library with STATIC) to force static build?