Get VCPKG to include the VCPKG Include directory in the include path when building a port - vcpkg

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

Related

Why is my C++ symbol name different from the libtorrent library I'm linking to and does this cause linking to fail?

I'm trying to link a simple C++ program to libtorrent:
#include <libtorrent/add_torrent_params.hpp>
#include <libtorrent/magnet_uri.hpp>
int main(int argc, char const* argv[])
{
lt::add_torrent_params atp = lt::parse_magnet_uri(argv[1]);
}
I invoke cl.exe on the command line and it tells me that I have unresolved external symbols:
>cl /EHsc /Fefoo.exe /I<snip>\vcpkg\installed\x86-windows\include main.cpp torrent-rasterbar.lib /link /LIBPATH:<snip>\vcpkg\installed\x86-windows\lib
Microsoft (R) C/C++ Optimizing Compiler Version 19.34.31937 for x86
Copyright (C) Microsoft Corporation. All rights reserved.
main.cpp
Microsoft (R) Incremental Linker Version 14.34.31937.0
Copyright (C) Microsoft Corporation. All rights reserved.
/out:foo.exe
/LIBPATH:C:\Users\rages\code\vcpkg\installed\x86-windows\lib
main.obj
torrent-rasterbar.lib
main.obj : error LNK2019: unresolved external symbol "public: __thiscall libtorrent::add_torrent_params::~add_torrent_params(void)" (??1add_torrent_params#libtorrent##QAE#XZ) referenced in function _main
main.obj : error LNK2019: unresolved external symbol "struct libtorrent::add_torrent_params __cdecl libtorrent::parse_magnet_uri(class boost::basic_string_view<char,struct std::char_traits<char> >)" (?parse_magnet_uri#libtorrent##YA?AUadd_torrent_params#1#V?$basic_string_view#DU?$char_traits#D#std###boost###Z) referenced in function _main
foo.exe : fatal error LNK1120: 2 unresolved externals
Running dumpbin /exports on torrent-rasterbar.lib and looking for the add_torrent_params symbol shows me this:
??1add_torrent_params#v2#libtorrent##QAE#XZ (public: __thiscall libtorrent::v2::add_torrent_params::~add_torrent_params(void))
This is very different from what the compiler is complaining about. I suspect this is what's causing the linker to fail, but I'm not quite sure what I need to do differently to make it work. How do I get my compiler and the library to agree on the symbol names?
This was caused by a missing define. The libtorrent build page is very clear about this:
A common mistake when building and linking against libtorrent is to build with one set of configuration options (#defines) and link against it using a different set of configuration options. Since libtorrent has some code in header files, that code will not be compatible with the built library if they see different configurations.
Always make sure that the same TORRENT_* and BOOST_* macros are defined when you link against libtorrent as when you build it. The simplest way to see the full list of macros defined is to build libtorrent with -n -a switches added to b2 command line, which output all compiler switches.
So I began investigating how vcpkg was building libtorrent. I was able to find some output at $VCPKG_DIR/buildtrees/libtorrent/install-x64-windows-rel-out.log which showed me all the flags that it was passing to cl for each file. Sure enough, passing every single flag there got my code to compile.
By a process of elimination, I found that TORRENT_NO_DEPRECATE is the magic sauce that makes it work. Here's the bare minimum you need to get it to compile:
> cl -DTORRENT_NO_DEPRECATE /nologo /EHsc /Fefoo.exe /IE:\vcpkg\installed\x64-windows\include main.cpp torrent-rasterbar.lib /link /LIBPATH:E:\vcpkg\installed\x64-windows\lib main.cpp
Please note this is just for illustrating a solution to the specific issue of mismatched symbols. You should probably use the full set of defines found in the vcpkg log to make sure there are no surprises down the road from other headers.

Static library not linking correctly

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.

wxWidgets not linking using Cmake from VSCode (MSVC)

Problem
I am getting linker errors when building my project. The project has no trouble finding wxWidgets headers. I have looked at the wxWidgets minimal example and recreated it in order to verify that my build from source worked properly. I used cmake in VSCode to do the build using the cmake extension.
The wxWidgets cmake generated fine and the build of wxwidgets appears to have gone fine. I am using the Visual Studio 2022 amd64 toolset to do the compile. (I installed VS2022 Community Edition for the compiler only).
It looks like it is building DLL for the libraries. I would prefer static libraries but for an initial run I didnt think it mattered. I link my application to wx::net wx::core wx::base as recommended. I thought that this would take care of linking when I go to build.
When I go to build my overall application utilizing the wxWidgets library, I get these linker errors.
What am I doing wrong here? Im obviously not configuring something correctly for it to find the library, but I am kind of stumped here.
Linker Errors
[build] ProjectName.obj : error LNK2001: unresolved external symbol "protected: static class wxAppConsole * (__cdecl* wxAppConsoleBase::ms_appInitFn)(void)" -snipped-
[build] ProjectName.obj : error LNK2001: unresolved external symbol "protected: static class wxAppConsole * wxAppConsoleBase::ms_appInstance" -snipped-
[build] MainWindow.obj : error LNK2001: unresolved external symbol "void (__cdecl* wxTheAssertHandler)(class wxString const &,int,class wxString const &,class wxString const &,class wxString const &)"-snipped-
[build] MainWindow.obj : error LNK2001: unresolved external symbol "bool wxTrapInAssert" (?wxTrapInAssert##3_NA) -snipped-
[build] MainWindow.obj : error LNK2001: unresolved external symbol "class wxMBConv * wxConvLibcPtr" (?wxConvLibcPtr##3PEAVwxMBConv##EA) -snipped-
[build] MainWindow.obj : error LNK2001: unresolved external symbol "public: static unsigned __int64 const wxString::npos" (?npos#wxString##2_KB)-snipped-
[build] MainWindow.obj : error LNK2001: unresolved external symbol "class wxSize const wxDefaultSize" (?wxDefaultSize##3VwxSize##B)-snipped-
[build] MainWindow.obj : error LNK2001: unresolved external symbol "class wxPoint const wxDefaultPosition" (?wxDefaultPosition##3VwxPoint##B)-snipped-
[build] MainWindow.obj : error LNK2001: unresolved external symbol "char const * const wxFrameNameStr" (?wxFrameNameStr##3QBDB)-snipped-
[build] C:\path\to\executable\ProjectName.exe : fatal error LNK1120: 9 unresolved externals -snipped-
[build] Build finished with exit code 1
Project Layout
Pretty basic project layout. I am building a GUI application and I am logically separating out the ui source code.
This is basically a recreation of the minimal wxWidgets example where you have an entry point (Projectname.hpp and ProjectName.cpp provide this) and a main window/frame (MainWindow.hpp and MainWindow.cpp provide this). The ProjectName application will do the wxIMPLEMENT_APP(ProjectName) and will hold a pointer to a MainWindow. The MainWindow is shown using the OnInit Function.
ProjectName/
build/
external/
wxWidgets-3.1.6/
-CMakeLists.txt
source/
ui/
-MainWindow.hpp
-MainWindow.cpp
-ProjectName.hpp
-ProjectName.cpp
-CMakeLists.txt
I have compiled the wxWidgets library using their cmake instructions for using a subdirectory in cmake so I could add it to my project. Here are the contents of the CMakeLists.txt's
ProjectName CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
set(MAJOR 0)
set(MINOR 0)
set(PATCH 1)
#Setup Project
project(ProjectNameProject VERSION ${MAJOR}.${MINOR}.${PATCH}
DESCRIPTION "ProjectName Descrip"
LANGUAGES CXX)
add_executable(ProjectName WIN32 ${PROJECT_SOURCE_DIR}/source/ProjectName.cpp
${PROJECT_SOURCE_DIR}/source/ui/MainWindow.cpp)
target_include_directories(ProjectName PRIVATE ${PROJECT_SOURCE_DIR}/source)
target_include_directories(ProjectName PRIVATE ${PROJECT_SOURCE_DIR}/source/ui)
target_link_libraries(ProjectName PRIVATE wx::net wx::core wx::base)
add_subdirectory(${CMAKE_SOURCE_DIR}/external)
ProjectName/externals CMakeLists.txt
cmake_minimum_required(VERSION 3.23)
add_subdirectory(${CMAKE_SOURCE_DIR}/external/wxWidgets-3.1.6)
Update
I changed the Cmake option for building a shared library (DLL) and set it to OFF. When this is done, it builds a static library (LIB). This seemed to fix my linking issues.
Per Igor's suggestion, I took another look at the minimal sample CMakeLists.txt and noticed they used the following line for linking
target_link_libraries(${PROJECT_NAME} ${wxWidgets_LIBRARIES})
Perhaps my line (below) is the way to link statically and does not work with DLLs?
target_link_libraries(ProjectName PRIVATE wx::net wx::core wx::base)
If someone could help me understand why having it build statically fixed it, I would 100% accept that answer.
I changed the Cmake option for building a shared library (DLL) and set it to OFF. When this is done, it builds a static library (LIB). This seemed to fix my linking issues.
Unfortunately I do no see anyone able to chime in to help understand why this is the solution, but I am going to select this as an answer for others coming to this in the future.
If I see any updates that answer the question of "why" I will accept their answer.

error LNK2019: unresolved external symbol referenced when compile HTTPD

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).

VS2012 fails to resolve printf,

I've just reinstalled VS2012, when trying to compile a simple "hello world" it failed to find the most basic functions, I've tried going through linking options or compiler options for c++ looking for nostd or some similar option from GCC but failed to do so
can anyone hint me what am I missing ? this is obviously a configuration problem I can't seem to resolve
just to clear thing, when I use cl from the command line "cl test.cpp -o test.exe" it works, this means it is some configuration problem I'm missing
can anyone help out ?
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Build started 8/24/2013 1:52:58 PM.
1>InitializeBuildStatus:
1> Touching "Debug\test.unsuccessfulbuild".
1>ClCompile:
1> test.cpp
1>LINK : warning LNK4044: unrecognized option '/map(filename)'; ignored
1>test.obj : error LNK2019: unresolved external symbol __imp__printf referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _main
1>test.obj : error LNK2001: unresolved external symbol __RTC_InitBase
1>test.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1>C:\_projects\code\c\test\Debug\test.exe : fatal error LNK1120: 5 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.47
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
here's the same error after adding a subsystem and entrypoint
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>Build started 8/24/2013 2:37:29 PM.
1>InitializeBuildStatus:
1> Touching "Debug\test.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>LINK : warning LNK4044: unrecognized option '/map(filename)'; ignored
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/RELEASE' specification
1>main.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
1>main.obj : error LNK2019: unresolved external symbol __imp__printf referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol __RTC_CheckEsp referenced in function _main
1>main.obj : error LNK2001: unresolved external symbol __RTC_InitBase
1>main.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
1>C:\_projects\code\C\test\Debug\test.exe : fatal error LNK1120: 4 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.17
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
just to note, this is a console project
linker options:
/OUT:"C:\_projects\code\C\test\Debug\test.exe" /MANIFEST /NXCOMPAT /PDB:"C:\_projects\code\C\test\Debug\test.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG /MACHINE:X86 /ENTRY:"_tmain" /INCREMENTAL /PGD:"C:\_projects\code\C\test\Debug\test.pgd" /SUBSYSTEM:WINDOWS /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /ManifestFile:"Debug\test.exe.intermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1
c/c++ options:
/Yu"stdafx.h" /MP /GS /analyze- /W3 /Zc:wchar_t /ZI /Gm /Od /sdl /Fd"Debug\vc110.pdb" /fp:precise /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /fp:except- /errorReport:prompt /WX- /Zc:forScope /RTC1 /GR- /Gd /Oy- /MDd /Fa"Debug\" /nologo /Fo"Debug\" /Fp"Debug\test.pch"
It has been asked several times here all around, but the problem is that you have not selected "Console" application type, but rather the win32 gui. You need to be careful about the proper linker selection, too.