oatpp / example-api-client

Example project how-to use oatpp ApiClient and how it works
https://oatpp.io/
Apache License 2.0
25 stars 12 forks source link

Trouble compiling in Windows #4

Closed hcort closed 4 years ago

hcort commented 4 years ago

I'm having some trouble running this example on Windows.

I installed oatcpp and oatcpp-curl using vcpkg and ran CMake on this example-api-client:

 cmake -A win32 ..
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/.../example-api-client-master/build
PS C:\Users\...\example-api-client-master> cd .\build\
PS C:\Users\...\example-api-client-master\build> cmake -A win32 ..
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19041.
-- The C compiler identification is MSVC 19.27.29111.0
-- The CXX compiler identification is MSVC 19.27.29111.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x86/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/.../example-api-client-master/build

After pointing the Visual Studio project to the path of the libraries (in my case C:\dev\vcpkg\installed\x86-windows\lib\oatpp-1.0.0) and the includes (C:/dev/vcpkg/installed/x86-windows/include/oatpp-1.0.0/) I still get the following linker errors:

1>oatpp-curl.lib(RequestExecutor.cpp.obj) : error LNK2019: símbolo externo "public: __thiscall oatpp::data::mapping::type::Type::Type(class oatpp::data::mapping::type::ClassId const &,char const *)" (??0Type@type@mapping@data@oatpp@@QAE@ABVClassId@1234@PBD@Z) sin resolver al que se hace referencia en la función "public: static class oatpp::data::mapping::type::Type * __cdecl oatpp::data::mapping::type::__class::String::getType(void)" (?getType@String@__class@type@mapping@data@oatpp@@SAPAVType@3456@XZ)
1>oatpp-curl.lib(CurlHeadersReader.cpp.obj) : error LNK2001: símbolo externo "public: __thiscall oatpp::data::mapping::type::Type::Type(class oatpp::data::mapping::type::ClassId const &,char const *)" (??0Type@type@mapping@data@oatpp@@QAE@ABVClassId@1234@PBD@Z) sin resolver
1>C:\Users\Hector\CLionProjects\example-api-client-master\build\Debug\example-api-client-exe.exe : fatal error LNK1120: 1 externos sin resolver
1>Compilación del proyecto "example-api-client-exe.vcxproj" terminada -- ERROR.
========== Compilar: 0 correctos, 1 incorrectos, 1 actualizados, 0 omitidos ==========
lganzzzo commented 4 years ago

Hello @hcort ,

The oatpp version 1.0.0 is outdated and there were some breaking changes introduced since 1.1.0. Also, at the moment, it's recommended to install oatpp from the source.

Please find this page - https://oatpp.io/docs/installation/windows/ - info on how-to install oatpp on Windows from the source (for oatpp-curl the same set of commands applies).

Once installed there should be no problems of generating a solution or to just open "cmake" in the visual-studio.

The only problem you'll find is the oatpp-curl module which depends on pkg-config to find libcurl. If you manage to overcome this obstacle, everything else should go smoothly.

Regards, Leonid

hcort commented 4 years ago

Hi @lganzzzo

I managed to build from source both libraries, oatcpp and oatcpp-curl but I'm getting the same linker errors.

lganzzzo commented 4 years ago

Hello @hcort ,

Please tell me more:

I need to reproduce it.

Regards, Leonid

hcort commented 4 years ago

Hi @lganzzzo

I fixed it. There was a missing path in the "Library directories" project configuration.

Now the example runs fine.

lganzzzo commented 4 years ago

Hey,

Thanks for the info!

Please let me know if you have more questions!

Regards, Leonid