I'm compiling HTTPD 2.4.48 along with Lua, Zlib, cURL, jansson and OpenSSL.
Here is the list of files and software I use:
httpd-2.4.48
apr-1.7.0
apr-util-1.6.1
cURL 7.77.0
expat-2.4.1
jansson 2.13.1
Lua 5.4.3
mod_fcgid 2.3.9
openssl-1.1.1k
pcre-8.44
ZLIB 1.2.11
ActivePerl v5.28.1.2801 (x64)
CMake v3.20.3 (x64)
NASM v2.15.05 (x64)
Gawk v3.1.6-1 (x86)
The whole compile statement I use:
Visual Studio 2015: call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
*****************
** ZLIB Build **
*****************
cd /D C:\httpd\srclib\zlib\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
nmake
nmake install
****************
** Pcre Build **
****************
cd /D C:\httpd\srclib\pcre\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DPCRE_BUILD_TESTS=OFF -DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_SUPPORT_PCREGREP_JIT=OFF -DPCRE_SUPPORT_UTF=ON -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_NEWLINE=CRLF -DINSTALL_MSVC_PDB=OFF ..
nmake
nmake install
*****************
** Expat Build **
*****************
cd /D C:\httpd\srclib\expat\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
nmake
nmake install
*******************
** OpenSSL Build **
*******************
cd /D C:\httpd\srclib\openssl
perl Configure VC-WIN64A --release --prefix=\phpStudy\Apache --openssldir=\phpStudy\Apache\conf enable-camellia no-idea no-mdc2 no-ssl2 no-ssl3
nmake
nmake install
***************
** Lua Build **
***************
cd /D C:\httpd\srclib\lua\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release ..
nmake
nmake install
****************
** cURL Build **
****************
cd /D C:\httpd\srclib\curl\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
nmake
nmake install
*******************
** jansson Build **
*******************
cd /D C:\httpd\srclib\jansson\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
nmake
nmake install
***************
** APR Build **
***************
cd /D C:\httpd\srclib\apr\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DMIN_WINDOWS_VER=0x0600 -DAPR_HAVE_IPV6=ON -DAPR_INSTALL_PRIVATE_H=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..
nmake
nmake install
********************
** APR-Util Build **
********************
cd /D C:\httpd\srclib\apr-util\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DOPENSSL_ROOT_DIR=\phpStudy\Apache -DAPU_HAVE_CRYPTO=ON -DAPR_BUILD_TESTAPR=OFF -DINSTALL_PDB=OFF ..
nmake
nmake install
******************
** Apache Build **
******************
cd /D C:\httpd\bin
cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=\phpStudy\Apache -DCMAKE_BUILD_TYPE=Release -DENABLE_MODULES=i -DINSTALL_PDB=OFF ..
nmake
nmake install
Everything worked almost perfectly, however in the last step when I compile HTTPD I got the error:
[ 44%] Linking C shared library mod_md.so
LINK: command "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\link.exe /nologo #CMakeFiles\mod_md.dir\objects1.rsp /out:mod_md.so /implib:mod_md.lib /pdb:C:\httpd\bin\mod_md.pdb /dll /version:0.0 /base:#C:/httpd/bin/BaseAddr.ref,mod_md.so /machine:x64 /INCREMENTAL:NO \phpStudy\Apache\lib\libssl.lib \phpStudy\Apache\lib\libcrypto.lib \phpStudy\Apache\lib\jansson.lib mod_watchdog.lib libhttpd.lib \phpStudy\Apache\lib\libapr-1.lib \phpStudy\Apache\lib\libaprutil-1.lib \phpStudy\Apache\lib\apr_ldap-1.lib ws2_32.lib mswsock.lib \phpStudy\Apache\lib\pcre.lib ws2_32.lib mswsock.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:mod_md.so.manifest" failed (exit code 1120) with the following output:
Creating library mod_md.lib and object mod_md.exp
md_curl.c.obj : error LNK2019: unresolved external symbol curl_global_init referenced in function md_curl_init
md_curl.c.obj : error LNK2019: unresolved external symbol curl_slist_append referenced in function curlify_headers
md_curl.c.obj : error LNK2019: unresolved external symbol curl_slist_free_all referenced in function md_curl_req_cleanup
md_curl.c.obj : error LNK2019: unresolved external symbol curl_easy_strerror referenced in function md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_easy_init referenced in function internals_setup
md_curl.c.obj : error LNK2019: unresolved external symbol curl_easy_setopt referenced in function internals_setup
md_curl.c.obj : error LNK2019: unresolved external symbol curl_easy_perform referenced in function md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_easy_cleanup referenced in function md_curl_req_cleanup
md_curl.c.obj : error LNK2019: unresolved external symbol curl_easy_getinfo referenced in function md_curl_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_init referenced in function md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_add_handlereferenced in function md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_remove_handle referenced in function md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_wait referenced in function md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_perform referenced in function md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_cleanup referenced in function md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_info_read referenced in function md_curl_multi_perform
md_curl.c.obj : error LNK2019: unresolved external symbol curl_multi_strerror referenced in function md_curl_multi_perform
mod_md.so : fatal error LNK1120: 17 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\nmake.exe"' : return code '0x2'
Stop.
I found out the answer of this question: Visual Studio 2015 curl will not statically link
Change the code of the md_curl.c file to:
#pragma comment(lib, "wldap32.lib" )
#pragma comment(lib, "crypt32.lib" )
#pragma comment(lib, "Ws2_32.lib")
#define CURL_STATICLIB
#include <curl/curl.h>
But this error still occurs.
Where did I go wrong? I'm getting confused because this is the first time I've encountered this error when compiling HTTPD.
Your answer will be very helpful. I would appreciate that!
Whenever you fix issues, start by the first one (cause solving that may remove the remaining), which in you case seems to be:
error LNK2019: unresolved external symbol curl_global_init referenced in function md_curl_init
And it basically is telling us that, the md_curl_init method calls curl_global_init method, but while compile-time declaration was available, the linker-time required definition is missing.
Anyway, to fix this ensure curl is added as a library, I mean, is currently not in your linker command-line (not in what you posted at least).
Edit I will suggest you approaches, for how you can do that.
But first, giving it more time, I see that:
Yes, you already compile curl.
Your "whole compile statement" thing is using C:\httpd\srclib\curl\bin as build-directory for cURL.
Also, you should be able to find curl.lib in C:\httpd\srclib\curl\bin directory (which was used as build-directory).
Approach #1:
Create a root CMakeFiles.txt file and add your other projects with add_subdirectory(...) method.
I recommend this approach, as CMake will handle for you the task of finding curl automatically.
I mean, you just would need to do something like:
target_link_libraries(myTargetThatNeedsCurl
curl
)
Approach #2:
If you don't want to change "whole compile statement" thing, then your only choice may be to place curl.lib somewhere that your other build-script can find it (manually or through some custom install(...) method calls, I leave that to you).
Approach #3:
First, edit httpd project (the C:\httpd\CMakeFiles.txt file), and add add_subdirectory(srclib/curl) somewhere in beginning.
Then, find cURL target's name, like, open the C:\httpd\srclib\curl\CMakeFiles.txt file and see all add_library(...) call's first argument (one of them is what we want).
Finally, edit httpd project again, but now add what you found in step-2 as argument to target_link_libraries(...) method.
Note that Approach #3 is same as #2, but just for cURL (instead of adding all sub-directories).
Related
sorry to bother you.
I know this is a commonly asked question and this is probably annoying to get again but I'm just completely stuck and not sure what I'm doing wrong.
I'm following learnopengl.com and trying to add assimp to my CLion project.
I created a new project quickly just so I know nothing is interfering.
I have a folder on my C drive where I placed in assimp library.
I downloaded it by following https://github.com/assimp/assimp/blob/master/Build.md with git and doing
cd assimp
cmake CMakeLists.txt
but changing the BUILD_SHARED_LIBS to OFF
Then I build the library with visual studio 2022 Using "Release x64" and the "Visual Studio 2022 (v143)" toolset
I link to the library with CMake as below.
I don't get an error message so I know that CMake finds the library.
I also have the location to the library setup in the PATH.
cmake_minimum_required(VERSION 3.22)
project(lemmefixbroken)
set(CMAKE_CXX_STANDARD 20)
set(LIB_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
add_executable(lemmefixbroken main.cpp)
# assimp
include_directories("C:/dev/libraries/assimp/include")
find_library(ASSIMP_LOCATION NAMES "assimp-vc143-mt" REQUIRED)
message(${ASSIMP_LOCATION})
target_link_libraries(${PROJECT_NAME} "${ASSIMP_LOCATION}")
My compiler settings are as below:
(Using the compiler located in Visual Studio 2022 and using the architecture amd64)
I've tried all the different architectures but none work.
The message returns "C:/dev/libraries/assimp/lib/Release/assimp-vc143-mt.lib" which is where its located
My code is:
#include <iostream>
#include "assimp/Importer.hpp"
int main()
{
std::cout << "Hello, World!" << std::endl;
Assimp::Importer import;
return 0;
}
When I build the code I get this error:
"C:\Program Files\JetBrains\CLion 2022.1.1\bin\cmake\win\bin\cmake.exe" --build C:\Users\charl\CLionProjects\lemmefixbroken\cmake-build-release --target all -j 9
[1/2] Building CXX object CMakeFiles\lemmefixbroken.dir\main.cpp.obj
[2/2] Linking CXX executable lemmefixbroken.exe
FAILED: lemmefixbroken.exe
cmd.exe /C "cd . && "C:\Program Files\JetBrains\CLion 2022.1.1\bin\cmake\win\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\lemmefixbroken.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\link.exe /nologo CMakeFiles\lemmefixbroken.dir\main.cpp.obj /out:lemmefixbroken.exe /implib:lemmefixbroken.lib /pdb:lemmefixbroken.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console C:\dev\libraries\assimp\lib\Release\assimp-vc143-mt.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK: command "C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1433~1.316\bin\Hostx64\x64\link.exe /nologo CMakeFiles\lemmefixbroken.dir\main.cpp.obj /out:lemmefixbroken.exe /implib:lemmefixbroken.lib /pdb:lemmefixbroken.pdb /version:0.0 /machine:x64 /INCREMENTAL:NO /subsystem:console C:\dev\libraries\assimp\lib\Release\assimp-vc143-mt.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:lemmefixbroken.exe.manifest" failed (exit code 1120) with the following output:
assimp-vc143-mt.lib(AssbinLoader.obj) : error LNK2019: unresolved external symbol uncompress referenced in function "public: virtual void __cdecl Assimp::AssbinImporter::InternReadFile(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,struct aiScene *,class Assimp::IOSystem *)" (?InternReadFile#AssbinImporter#Assimp##UEAAXAEBV?$basic_string#DU?$char_traits#D#std##V?$allocator#D#2##std##PEAUaiScene##PEAVIOSystem#2##Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflate referenced in function "public: unsigned __int64 __cdecl Assimp::Compression::decompress(void const *,unsigned __int64,class std::vector<char,class std::allocator<char> > &)" (?decompress#Compression#Assimp##QEAA_KPEBX_KAEAV?$vector#DV?$allocator#D#std###std###Z)
assimp-vc143-mt.lib(unzip.obj) : error LNK2001: unresolved external symbol inflate
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateEnd referenced in function "public: bool __cdecl Assimp::Compression::close(void)" (?close#Compression#Assimp##QEAA_NXZ)
assimp-vc143-mt.lib(unzip.obj) : error LNK2001: unresolved external symbol inflateEnd
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateSetDictionary referenced in function "public: unsigned __int64 __cdecl Assimp::Compression::decompressBlock(void const *,unsigned __int64,char *,unsigned __int64)" (?decompressBlock#Compression#Assimp##QEAA_KPEBX_KPEAD1#Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateReset referenced in function "public: unsigned __int64 __cdecl Assimp::Compression::decompressBlock(void const *,unsigned __int64,char *,unsigned __int64)" (?decompressBlock#Compression#Assimp##QEAA_KPEBX_KPEAD1#Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateInit_ referenced in function "public: bool __cdecl Assimp::Compression::open(enum Assimp::Compression::Format,enum Assimp::Compression::FlushMode,int)" (?open#Compression#Assimp##QEAA_NW4Format#12#W4FlushMode#12#H#Z)
assimp-vc143-mt.lib(Compression.obj) : error LNK2019: unresolved external symbol inflateInit2_ referenced in function "public: bool __cdecl Assimp::Compression::open(enum Assimp::Compression::Format,enum Assimp::Compression::FlushMode,int)" (?open#Compression#Assimp##QEAA_NW4Format#12#W4FlushMode#12#H#Z)
assimp-vc143-mt.lib(unzip.obj) : error LNK2001: unresolved external symbol inflateInit2_
assimp-vc143-mt.lib(unzip.obj) : error LNK2019: unresolved external symbol crc32 referenced in function unzReadCurrentFile
assimp-vc143-mt.lib(unzip.obj) : error LNK2019: unresolved external symbol get_crc_table referenced in function unzOpenCurrentFile3
lemmefixbroken.exe : fatal error LNK1120: 9 unresolved externals
ninja: build stopped: subcommand failed.
I've tried compiling the library more times than I would like to count. I've tried using the 2019 compiler and nothing. I still get all the same errors.
I have no clue what I'm doing wrong but hopefully someone here will know.
I've also tried using shared libraries with no success.
I've updated Visual Studio 2022 and restarted my computer then compiling again and still nothing changes.
Those are all zlib symbols that are missing, which means you didn't link against that. Asset-Importer lists several dependencies:
zlib
zip-lib
unzip
pugi-xml
rapijson
clipper
draco
gtest
stb_image
utf8cpp
poly2tri
openddlparser
Since Findassimp.cmake uses an old path-based interface instead of the newer style of defining virtual targets that can have PUBLIC dependencies, you will need to link against those yourself. They're all in the library's source tree, but having never used the library I don't know if they get built as part of its build scripts of if you would need to do that yourself.
As you can see in the error messages, what failed is the linking process, not the compiling process.
I think your linker could not find the assimp library's '.lib' files.
Did you specify the path to the assimp library's '.lib' files in the project setting?
You could do this in 'VC++ Directories' or 'Linker/Input', though I'm not sure since I'm not using my computer at the moment.
I am attempting to create a new port for VCPKG, for the Arabica project. The vcpkg install command is failing. The first error is as follows.
...\include\XPath/impl/xpath_namespace_context.hpp(7,10):
fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp':
No such file or directory [D:\vcpkg\buildtrees\arabica\x64-windows-dbg\mangle.vcxproj]
The thing is that this file is installed in the VCPKG include directory. To be precise it is installed at D:\vcpkg\installed\x64-windows\include\boost\shared_ptr.hpp.
The command used to compile the file is as follows.
...\CL.exe /c /I"D:\vcpkg\buildtrees\arabica\x64-windows-dbg\include" /I"D:\vcpkg\buildtrees\arabica\src\0-February-67b234ed05\include" /Z7 /W3 /WX- /diagnostics:column /MP /Od /Ob0 /D WIN32 /D _WINDOWS /D _DEBUG /D ARABICA_DEBUG /D ARABICA_NOT_USE_PRAGMA_LINKER_OPTIONS /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"xgrep.dir\Debug\\" /Fd"xgrep.dir\Debug\vc142.pdb" /Gd /TP /errorReport:queue /utf-8 "D:\vcpkg\buildtrees\arabica\src\0-February-67b234ed05\examples\XPath\xgrep.cpp"
If I could just get VCPKG to add the /I"D:\vcpkg\installed\x64-windows\include" command line argument it would work.
The contents of my CONTROL file is as follows.
Source: arabica
Version: 2020-February
Homepage: https://github.com/BenKeyFSI/arabica
Description: Arabica is an XML and HTML processing toolkit, providing SAX2, DOM, XPath, and XSLT implementations, written in Standard C++.
Build-Depends: boost-mpl, boost-type-traits, boost-spirit, boost-function, boost-bind, boost-smart-ptr, boost-lexical-cast
The contents of the portfile.cmake is as follows.
include(vcpkg_common_functions)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO BenKeyFSI/arabica
REF 2020-February
SHA512 3cf56a71c53e35eb2bc48332c96958e6800e5735a629f292f47e9b22b106f378e45abe046d6a7ed8604fe434d356efbf8744bd31fa905de6fcec62c7223f9e4c
HEAD_REF master
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
vcpkg_install_cmake()
vcpkg_copy_pdbs()
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/arabica RENAME copyright)
This is failing with the compiler error I mentioned above and several other due to missing Boost header files. None of these compiler errors would occur if it would just include the VCPKG include directory in the list of include directories since Boost is already installed and the CONTROL file states that this library depends on Boost.
Is there a magical incantation I need to pass to either vcpkg_configure_cmake or vcpkg_install_cmake that says "include the VCPKG include directory in the include path?"
If I could just get VCPKG to add the /I"D:\vcpkg\installed\x64-windows\include" command line argument it would work.
You don't need to convince vcpkg to do that but cmake. So just replace your vcpkg_configure_cmake call with:
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS -DBUILD_WITH_BOOST=ON
)
to actually do the find_package call for boost in your CMakeLists.txt. (Actually BUILD_WITH_BOOST seems like a non option since it is build requirement?!?!). It is also better to link against the Boost::headers target since this would have thrown a CMake error if the target is unavailable.
It will then build but fail to link with the following errors (triplet x64-windows):
taggle.cpp.obj : error LNK2001: unresolved external symbol "public: static int const Arabica::SAX::Schema::M_ANY" (?M_ANY#Schema#SAX#Arabica##2HB)
taggle.cpp.obj : error LNK2001: unresolved external symbol "public: static int const Arabica::SAX::Schema::M_EMPTY" (?M_EMPTY#Schema#SAX#Arabica##2HB)
taggle.cpp.obj : error LNK2001: unresolved external symbol "public: static int const Arabica::SAX::Schema::M_PCDATA" (?M_PCDATA#Schema#SAX#Arabica##2HB)
taggle.cpp.obj : error LNK2001: unresolved external symbol "public: static int const Arabica::SAX::Schema::M_ROOT" (?M_ROOT#Schema#SAX#Arabica##2HB)
taggle.cpp.obj : error LNK2001: unresolved external symbol "public: static int const Arabica::SAX::Schema::F_RESTART" (?F_RESTART#Schema#SAX#Arabica##2HB)
taggle.cpp.obj : error LNK2001: unresolved external symbol "public: static int const Arabica::SAX::Schema::F_CDATA" (?F_CDATA#Schema#SAX#Arabica##2HB)
taggle.cpp.obj : error LNK2001: unresolved external symbol "public: static int const Arabica::SAX::Schema::F_NOFORCE" (?F_NOFORCE#Schema#SAX#Arabica##2HB)
taggle.exe : fatal error LNK1120: 7 unresolved externals
So I assume your CMakeLists.txt has logical errors if internal symbols cannot be found. (Building x64-windows-static is successful so it is a symbol visibility problem)
you also need to add
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
to your portfile.cmake
Im trying to link Qt Creator to Clion so i can use it for creating GUI elements but the only information I was able to find on doing this was this thread
How to configure CLion IDE for Qt Framework?
I tried to follow this as closely as possible but one of the major differences is that on windows there is no clang_64 file instead it is msvc2017_64 and that is what seems to be showing up in the error im getting.
My CmakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(helloqt)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(SOURCE_FILES main.cpp)
find_package(Qt5Widgets REQUIRED)
add_executable(helloqt ${SOURCE_FILES})
target_link_libraries(helloqt Qt5::Widgets)
my main.cpp
#include <QApplication>
#include <QDebug>
using namespace std;
int main() {
qDebug() << QT_VERSION_STR;
return 1;
}
under Settings>Build, Execution, Deployment > CMake my Cmake Options has the path
-DCMAKE_PREFIX_PATH=C:/Qt/5.12.1/msvc2017_64/lib/cmake
and it results in this error which I have not been able to find a fix to.
"C:\Program Files\JetBrains\CLion 2018.3.4\bin\cmake\win\bin\cmake.exe" --build C:\Users\Uncorropto\CLionProjects\helloqt\cmake-build-debug --target helloqt --
Scanning dependencies of target helloqt
[ 50%] Building CXX object CMakeFiles/helloqt.dir/main.cpp.obj
main.cpp
[100%] Linking CXX executable helloqt.exe
LINK Pass 1: command "C:\PROGRA~2\MIB055~1\2017\COMMUN~1\VC\Tools\MSVC\1414~1.264\bin\Hostx86\x86\link.exe /nologo #CMakeFiles\helloqt.dir\objects1.rsp /out:helloqt.exe /implib:helloqt.lib /pdb:C:\Users\Uncorropto\CLionProjects\helloqt\cmake-build-debug\helloqt.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console C:\Qt\5.12.1\msvc2017_64\lib\Qt5Widgetsd.lib C:\Qt\5.12.1\msvc2017_64\lib\Qt5Guid.lib C:\Qt\5.12.1\msvc2017_64\lib\Qt5Cored.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\helloqt.dir/intermediate.manifest CMakeFiles\helloqt.dir/manifest.res" failed (exit code 1120) with the following output:
main.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QMessageLogger::QMessageLogger(char const *,int,char const *)" (__imp_??0QMessageLogger##QAE#PBDH0#Z) referenced in function _main
main.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QDebug __thiscall QMessageLogger::debug(void)const " (__imp_?debug#QMessageLogger##QBE?AVQDebug##XZ) referenced in function _main
main.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QDebug::~QDebug(void)" (__imp_??1QDebug##QAE#XZ) referenced in function _main
main.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class QDebug & __thiscall QDebug::operator<<(char const *)" (__imp_??6QDebug##QAEAAV0#PBD#Z) referenced in function _main
C:\Qt\5.12.1\msvc2017_64\lib\Qt5Widgetsd.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
C:\Qt\5.12.1\msvc2017_64\lib\Qt5Guid.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
C:\Qt\5.12.1\msvc2017_64\lib\Qt5Cored.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'
helloqt.exe : fatal error LNK1120: 4 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\JetBrains\CLion 2018.3.4\bin\cmake\win\bin\cmake.exe"' : return code '0xffffffff'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\nmake.exe"' : return code '0x2'
Stop.
It can't find symbol like QMessageLogger which is part of Qt Core. Note you have used qDebug() which refers to this symbols!
Conclusion is simple add this to your CMakeLists.txt:
find_package(Qt5Core REQUIRED) # this might be not needed
target_link_libraries(helloqt Qt5::Widgets Qt5::Core)
Offtopic: trash this:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
since it doesn't do anything.
Try this under project(helloqt):
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
I try to use dlib in Qt project on Windows. After downloading I at once started to try build my Qt application, without building examples. I also downloaded static libraries libpng and libjpeg from GnuWin.
.pro file:
SOURCES += main.cpp\
mainwindow.cpp \
C:/Users/user/Downloads/dlib-19.0/dlib-19.0/dlib/all/source.cpp
HEADERS += mainwindow.h
INCLUDEPATH += "C:\Users\user\Downloads\dlib-19.0\dlib-19.0"
LIBS += -L"C:\Users\user\Downloads\dlib-19.0\dlib-19.0"
INCLUDEPATH += "C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\external\libpng"
INCLUDEPATH += "C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\external\libjpeg"
LIBS += -L"C:\Users\user\Downloads\jpeg-6b-4-lib\lib" -ljpeg
LIBS += -L"C:\Users\user\Downloads\libpng-1.2.37-lib\lib" -lpng
LIBS += -lwinmm -lws2_32 -luser32 -lgdi32 -lcomctl32 -limm32
QMAKE_CXXFLAGS += -std=c++11 -DDLIB_PNG_SUPPORT -DDLIB_JPEG_SUPPORT
Code:
try
{
array2d<rgb_pixel> img;
load_image(img, "C:\\Users\\user\\Downloads\\test.jpg");
}
catch (exception& e)
{
cout << "\nexception thrown!" << endl;
cout << e.what() << endl;
}
MinGW output:
png_loader.cpp:103: undefined reference to 'png_set_longjmp_fn'
png_loader.cpp:153: undefined reference to 'png_set_longjmp_fn'
save_png.cpp:20: undefined reference to 'png_set_longjmp_fn'
save_png.cpp:72: undefined reference to 'png_set_longjmp_fn'
I know that I need to use libpng 1.4, but I can't find this version in GnuWin, so I used the most relevant 1.2.
MSVC runtime exception:
exception thrown!
Unable to load image in file C:\Users\user\Downloads\test.jpg.
You must #define DLIB_JPEG_SUPPORT and link to libjpeg to read JPEG
files.
Do this by following the instructions at http://dlib.net/compile.html.
Note that you must cause DLIB_JPEG_SUPPORT to be defined for your
entire project.
So don't #define it in one file. Instead, add it to the
C/C++->Preprocessor->Preprocessor Definitions
field in Visual Studio's Property Pages window so it takes effect for
your entire application.
But I set -DDLIB_JPEG_SUPPORT in my .pro file, linked with jpeg and png and even downloaded in the working folder shared library jpeg.dll.
How can I solve this probles or how can I use dlib in Qt on Windows?
UPD:
Errors after E:\CMake\bin\cmake.exe --build . --config Release:
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\3d_point_cloud_ex.vcxproj" (default target)
(3) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj" (default target) (4
) ->
(target ClCompile) ->
f:\gstreamer\1.0\x86\include\jmorecfg.h(211): error C2371: 'boolean': redefinition; different basic types [C:\Users\user
\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
C:\Program Files (x86)\Windows Kits\8.1\Include\shared\basetsd.h(72): error C2371: 'INT32': redefinition; different b
asic types [C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
c:\program files (x86)\windows kits\8.1\include\shared\rpcndr.h(178): error C2371: 'boolean': redefinition; different
basic types [C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
c:\program files (x86)\windows kits\8.1\include\shared\wtypesbase.h(493): error C2371: 'BOOLEAN': redefinition; diffe
rent basic types [C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
UPD2:
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\ALL_BUILD.vcxproj" (default target) (1) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\3d_point_cloud_ex.vcxproj" (default target) (3) ->
"C:\Users\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj" (default target) (4) ->
(target ClCompile) ->
C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\image_loader\jpeg_loader.cpp(17): fatal error C1083: Cannot open include file: 'jpeglib.h': No such file or directory [C:\U
sers\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
C:\Users\user\Downloads\dlib-19.0\dlib-19.0\dlib\image_saver\save_jpeg.cpp(16): fatal error C1083: Cannot open include file: 'jpeglib.h': No such file or directory [C:\User
s\user\Downloads\dlib-19.0\dlib-19.0\examples\build\dlib_build\dlib.vcxproj]
UPD3:
.pro file:
INCLUDEPATH += "E:\dlib_build\include"
LIBS += -L"E:\dlib_build"
LIBS += -ldlib
QMAKE_CXXFLAGS_RELEASE += /arch:AVX
QMAKE_CXXFLAGS += -std=c++11 -DDLIB_PNG_SUPPORT -DDLIB_JPEG_SUPPORT
MSVC 2015 64bit Release output:
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::entropy_decoder_kernel_2::entropy_decoder_kernel_2(void)" (??0entrop...
mainwindow.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl dlib::entropy_decoder_kernel_2::~entropy_decoder_kernel_2(void)" (...
mainwindow.obj : error LNK2019: unresolved external symbol "public: void __cdecl dlib::entropy_decoder_kernel_2::set_stream(class std::basic_istream<c...
mainwindow.obj : error LNK2019: unresolved external symbol "public: void __cdecl dlib::entropy_decoder_kernel_2::decode(unsigned int,unsigned int)" (?...
mainwindow.obj : error LNK2019: unresolved external symbol "public: unsigned int __cdecl dlib::entropy_decoder_kernel_2::get_target(unsigned int)" (?g...
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::png_loader::png_loader(class std::basic_string<char,struct std::char...
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::png_loader::~png_loader(void)" (??1png_loader#dlib##QEAA#XZ) referen...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_gray(void)const " (?is_gray#png_loader#dlib##QEB...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_graya(void)const " (?is_graya#png_loader#dlib##Q...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_rgb(void)const " (?is_rgb#png_loader#dlib##QEBA_...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::png_loader::is_rgba(void)const " (?is_rgba#png_loader#dlib##QEB...
mainwindow.obj : error LNK2019: unresolved external symbol "private: unsigned char const * __cdecl dlib::png_loader::get_row(unsigned int)const " (?ge...
mainwindow.obj : error LNK2019: unresolved external symbol "public: __cdecl dlib::jpeg_loader::jpeg_loader(class std::basic_string<char,struct std::ch...
mainwindow.obj : error LNK2019: unresolved external symbol "public: bool __cdecl dlib::jpeg_loader::is_gray(void)const " (?is_gray#jpeg_loader#dlib##Q...
mainwindow.obj : error LNK2019: unresolved external symbol USER_ERROR__missing_dlib_all_source_cpp_file__OR__inconsistent_use_of_DEBUG_or_ENABLE_ASSER...
E:\dlib_build\lib\dlib.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
release\dlibWindows.exe : fatal error LNK1120: 15 unresolved externals
jom: F:\Projects\QtProjects\build-dlibWindows-Desktop_Qt_5_6_0_MSVC2015_64bit-Release\Makefile.Release [release\dlibWindows.exe] Error 1120
UPD4:
.pro file:
INCLUDEPATH += "E:\dlib_build\include"
LIBS += -L"E:\dlib_build"
LIBS += -ldlib
QMAKE_CXXFLAGS_RELEASE += /arch:AVX
Code:
try
{
//or even just one line "frontal_face_detector detector = get_frontal_face_detector();"
array2d<rgb_pixel> img;
load_image(img, "C:/Users/user/Downloads/test.jpg");
}
catch (exception& e)
{
cout << "\nexception thrown!" << endl;
cout << e.what() << endl;
}
Release output:
Exited with code 255
You have chosen the way of compiling by incliding all/source.cpp into your project. This is possible but I think not the best way how to use dlib.
So if you want to use all/source.cpp in your project - please follow instructions from here: http://dlib.net/compile.html
Compiling on Windows Using Visual Studio
All you need to do is create an empty console project. Then add dlib/all/source.cpp to it and add the folder containing the dlib folder to the #include search path. Then you can compile any example program by adding it to your project.
Again, note that dlib will only be able to work with jpeg and png files if you link in libjpeg and libpng. In Visual Studio, the easiest way to do this is to add all the source files in the dlib/external folder into your project and also define the DLIB_PNG_SUPPORT and DLIB_JPEG_SUPPORT preprocessor directives. If you don't know how to configure Visual Studio then you should use CMake as shown above since it will take care of everything automatically.
And with adding dlib/external folder - you can remove libjpeg and libpng from your project.
But as I said - its not the best way how to compile dlib. Dlib is designed to be used with CMAKE and the best way is to build it with CMAKE.
Why this way is better:
no need to rebuild dlib every time your project changes
possible use of CUDA code (not now - but a bit later when CUDA 8 and VS update 4 will be released)
Here the first step (after installing CMAKE) should be checking if Dlib works. According to Dlib's instructions best way is to build examples and run them (from dlib's folder):
cd examples
mkdir build
cd build
cmake ..
cmake --build . --config Release
When running cmake .. you can specify your compiler version, for example:
cmake .. -G"Visual Studio 14 2015 Win64"
To build examples with Visual Studio 2015 x64
After testing examples its a good time to build Dlib and start using it in real projects. And yes, again build is done by CMAKE (from dlib folder):
mkdir build
cd build
cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_INSTALL_PREFIX=C:\Users\user\dlib
cmake --build . --config Release --target install
The building process is little different from building examples:
CMAKE_INSTALL_PREFIX=C:\Users\user\dlib - compiled dlib will be installed into C:\Users\user\dlib
--target install means we are installing dlib
After the building process will be finished - you are free to use dlib.lib (static version of Dlib) from C:\Users\user\dlib\lib. If you will use CMAKE with your project - you will need to add -DCMAKE_PREFIX_PATH=c:\Users\user\dlib. But now you are trying to compile with Qt Creator (QMake). Here is your .pro file should look like (the minimal possible example):
SOURCES += face_detection_ex.cpp
INCLUDEPATH += "C:\Users\user\dlib\include"
LIBS += -L"C:\Users\user\dlib"
LIBS += -ldlib
QMAKE_CXXFLAGS_RELEASE += /arch:AVX
This project will not compile and run in Debug mode build because we used --config Release in our building process. But Release mode will run very fast
Please note
Visual Studio will need separate dlib installation for Release and Debug builds. And Debug build of Dlib will be extremely slow
Adding /arch:AVX to compiler flags (MSVC) will make Dlib run much faster
DNN module will not work under MSVC until Cuda 8 and MSVC 2015 update 4 will be released
1.Download source from OpenSSL (openssl-1.0.0d).
2.Build it static using this:
> perl Configure VC-WIN32 no-asm --prefix=d:\Miatar\cpplibs\openssl
> ms\do_ms
> nmake -f ms\nt.mak
> nmake -f ms\nt.mak install
3.Download qt-everywhere-opensource-src-4.7.1,
patching it (QTDIR\mkspecs\win32-msvc2010\qmake.conf - /MD to /MT and /MDd to /MTd)
copying bin / lib / include folders of openssl to QTDIR bin / lib / include folders
and trying to build it using next *.bat
setlocal
set MAKEFLAGS=
call "D:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
set QMAKESPEC=win32-msvc2010
set PATH=%CD%\bin;%PATH%
configure -debug-and-release -platform win32-msvc2010 -static -no-crt -no-qt3support -nomake examples -nomake demos -openssl-linked -I "d:\Miatar\cpplibs\openssl\include" -L "d:\Miatar\cpplibs\openssl\lib"
nmake
pause
endlocal
getting error during nmake
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
"D:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" -f Makefile.Debug all
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MTd -MP -GR -EHsc -W3 -w34100 -w3 4189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_XMLPATTERNS_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"..\..\include\QtCore" -I"..\..\include\QtXmlPatterns" -I"..\..\include" -I"d:\Miatar\cpplibs\openssl\include" -I"..\..\include\ActiveQt" -I"tmp\moc\debug_static" -I"..\..\mkspecs\win32-msvc2010" -Fotmp\obj\debug_static\ #C:\Users\Daminian\AppData\Local\Temp\nm3A5A.tmp
main.cpp
qapplicationargument.cpp
qapplicationargumentparser.cpp
link /LIBPATH:"d:\Miatar\cpplibs\QtStaticSSL\lib" /LIBPATH:"d:\Miatar\cpplibs\QtStaticSSL\lib" /NOLOGO /DELAYLOAD:"OleAcc.dll" /DEBUG /SUBSYSTEM:CONSOLE /MANIFEST /MANIFESTFILE:"tmp\obj\debug_static\xmlpatterns.intermediate.manifest" /OUT:..\..\bin\xmlpatterns.exe #C:\Users\Daminian\AppData\Local\Temp\nm416C.tmp
LINK :
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__DeleteDC#4 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__DeleteObject#4 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__GetBitmapBits#12 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__BitBlt#36 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__GetObjectA#12 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__SelectObject#8 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleBitmap#12 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__GetDeviceCaps#8 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__CreateCompatibleDC#4 referenced in function _readscreen
libeay32.lib(rand_win.obj) : error LNK2019: unresolved external symbol __imp__CreateDCA#16 referenced in function _readscreen
..\..\bin\xmlpatterns.exe : fatal error LNK1120: 10 unresolved externals
NMAKE : fatal error U1077: '"D:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\link.EXE"' : return code '0x460'
Stop.
NMAKE : fatal error U1077: '"D:\Program Files\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
NMAKE : fatal error U1077: 'cd' : return code '0x2'
Stop.
any help? Here says that i can fix it by adding Gdi32.lib to your list of libraries. How to do that?
You have to add -L "path/to/dir/with/Gdi32library/" and -l Gdi32 params when you run configure.
Example: configure -L "C:/Program Files (x86)/Microsoft SDKs/Windows/v7.1A/Lib/" -l Gdi32