Please, I'm getting started Oat++ with the first project on the official website using Visual Studio 2022. There is no error in the code, but it failed on building. This is the code below.
#include "oatpp/web/server/HttpConnectionHandler.hpp"
#include "oatpp/network/Server.hpp"
#include "oatpp/network/tcp/server/ConnectionProvider.hpp"
#include <iostream>
using namespace oatpp;
using namespace oatpp::base;
using namespace oatpp::network;
using namespace oatpp::network::tcp;
using namespace oatpp::web;
using namespace oatpp::web::server;
void run() {
/* Create Router for HTTP requests routing */
auto router = HttpRouter::createShared();
/* Create HTTP connection handler with router */
auto connectionHandler = HttpConnectionHandler::createShared(router);
/* Create TCP connection provider */
auto connectionProvider = tcp::server::ConnectionProvider::createShared({"localhost", 8000, Address::IP_4});
/* Create server which takes provided TCP connections and passes them to HTTP connection handler */
Server server(connectionProvider, connectionHandler);
/* Print info about server port */
OATPP_LOGI("MyAPP", "Server running on port %s", connectionProvider->getProperty("port").getData());
/* Run server */
server.run();
}
int main(){
/* Init oatpp Environment */
Environment::init();
/* Run App */
run();
/* Destroy oatpp Environment */
Environment::destroy();
return 0;
}
and here is the build output:
Build started...
1>------ Build started: Project: OatWebApp01, Configuration: Debug x64 ------
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: static void __cdecl oatpp::base::Environment::init(void)" (?init@Environment@base@oatpp@@SAXXZ) referenced in function main
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: static void __cdecl oatpp::base::Environment::destroy(void)" (?destroy@Environment@base@oatpp@@SAXXZ) referenced in function main
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: static void __cdecl oatpp::base::Environment::logFormatted(unsigned int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char const *,...)" (?logFormatted@Environment@base@oatpp@@SAXIAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBDZZ) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: static class oatpp::data::mapping::type::Type * __cdecl oatpp::data::mapping::type::__class::String::getType(void)" (?getType@String@__class@type@mapping@data@oatpp@@SAPEAVType@3456@XZ) referenced in function "public: __cdecl oatpp::data::mapping::type::ObjectWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class oatpp::data::mapping::type::__class::String>::ObjectWrapper<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class oatpp::data::mapping::type::__class::String>(class std::shared_ptr<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > const &)" (??0?$ObjectWrapper@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@VString@__class@type@mapping@data@oatpp@@@type@mapping@data@oatpp@@QEAA@AEBV?$shared_ptr@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@std@@@Z)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: static __int64 __cdecl oatpp::utils::String::compareCI_ASCII(void const *,__int64,void const *,__int64)" (?compareCI_ASCII@String@utils@oatpp@@SA_JPEBX_J01@Z) referenced in function "public: bool __cdecl oatpp::data::share::StringKeyLabelCI::operator==(class oatpp::data::share::StringKeyLabelCI const &)const " (??8StringKeyLabelCI@share@data@oatpp@@QEBA_NAEBV0123@@Z)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: __cdecl oatpp::data::share::StringKeyLabelCI::StringKeyLabelCI(class oatpp::data::mapping::type::String const &)" (??0StringKeyLabelCI@share@data@oatpp@@QEAA@AEBVString@type@mapping@23@@Z) referenced in function "public: class oatpp::data::share::StringKeyLabel __cdecl oatpp::provider::Provider<class oatpp::data::stream::IOStream>::getProperty(class oatpp::data::mapping::type::String const &)const " (?getProperty@?$Provider@VIOStream@stream@data@oatpp@@@provider@oatpp@@QEBA?AVStringKeyLabel@share@data@3@AEBVString@type@mapping@63@@Z)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: static class std::shared_ptr<class oatpp::web::server::HttpRouter> __cdecl oatpp::web::server::HttpRouter::createShared(void)" (?createShared@HttpRouter@server@web@oatpp@@SA?AV?$shared_ptr@VHttpRouter@server@web@oatpp@@@std@@XZ) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: static class std::shared_ptr<class oatpp::web::server::HttpConnectionHandler> __cdecl oatpp::web::server::HttpConnectionHandler::createShared(class std::shared_ptr<class oatpp::web::server::HttpRouter> const &)" (?createShared@HttpConnectionHandler@server@web@oatpp@@SA?AV?$shared_ptr@VHttpConnectionHandler@server@web@oatpp@@@std@@AEBV?$shared_ptr@VHttpRouter@server@web@oatpp@@@6@@Z) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: __cdecl oatpp::network::Server::Server(class std::shared_ptr<class oatpp::network::ConnectionProvider> const &,class std::shared_ptr<class oatpp::network::ConnectionHandler> const &)" (??0Server@network@oatpp@@QEAA@AEBV?$shared_ptr@VConnectionProvider@network@oatpp@@@std@@AEBV?$shared_ptr@VConnectionHandler@network@oatpp@@@4@@Z) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl oatpp::network::Server::~Server(void)" (??1Server@network@oatpp@@UEAA@XZ) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: void __cdecl oatpp::network::Server::run(class std::function<bool __cdecl(void)>)" (?run@Server@network@oatpp@@QEAAXV?$function@$$A6A_NXZ@std@@@Z) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: __cdecl oatpp::network::Address::Address(class oatpp::data::mapping::type::String const &,unsigned short,enum oatpp::network::Address::Family)" (??0Address@network@oatpp@@QEAA@AEBVString@type@mapping@data@2@GW4Family@012@@Z) referenced in function "void __cdecl run(void)" (?run@@YAXXZ)
1>OatWebApp01.obj : error LNK2019: unresolved external symbol "public: __cdecl oatpp::network::tcp::server::ConnectionProvider::ConnectionProvider(class oatpp::network::Address const &,bool)" (??0ConnectionProvider@server@tcp@network@oatpp@@QEAA@AEBVAddress@34@_N@Z) referenced in function "void __cdecl std::_Construct_in_place<class oatpp::network::tcp::server::ConnectionProvider,class oatpp::network::Address const &,bool &>(class oatpp::network::tcp::server::ConnectionProvider &,class oatpp::network::Address const &,bool &)" (??$_Construct_in_place@VConnectionProvider@server@tcp@network@oatpp@@AEBVAddress@45@AEA_N@std@@YAXAEAVConnectionProvider@server@tcp@network@oatpp@@AEBVAddress@45@AEA_N@Z)
1>E:\H1LL4RY\Projects\cpp\OatPP\Learn\OatWebApp01\x64\Debug\OatWebApp01.exe : fatal error LNK1120: 13 unresolved externals
1>Done building project "OatWebApp01.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 18:17 and took 00.992 seconds ==========
Thanks in advance.
I've tried the solution Questions about third-party library(oat++) configuration in visual studio, but it did not work.