qinguoyi / TinyWebServer

:fire: Linux下C++轻量级WebServer服务器
Apache License 2.0
15.8k stars 3.8k forks source link

小白出问题了! #234

Closed Iamcodeking closed 11 months ago

Iamcodeking commented 1 year ago

在;Ubuntu解压后,数据库也写了,编译main.cpp的时候出现这样的问题,是哪一步错了,还是说所有的cpp都要编译一遍?真心求教!! g++ main.cpp -o server /tmp/cclDAZaL.o:在函数‘main’中: main.cpp:(.text+0xec):对‘Config::Config()’未定义的引用 main.cpp:(.text+0x10a):对‘Config::parse_arg(int, char**)’未定义的引用 main.cpp:(.text+0x119):对‘WebServer::WebServer()’未定义的引用 main.cpp:(.text+0x1e4):对‘WebServer::init(int, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::cxx11::basic_string<char, std::char_traits, std::allocator >, std::__cxx11::basic_string<char, std::char_traits, std::allocator >, int, int, int, int, int, int, int)’未定义的引用 main.cpp:(.text+0x224):对‘WebServer::log_write()’未定义的引用 main.cpp:(.text+0x233):对‘WebServer::sql_pool()’未定义的引用 main.cpp:(.text+0x242):对‘WebServer::thread_pool()’未定义的引用 main.cpp:(.text+0x251):对‘WebServer::trig_mode()’未定义的引用 main.cpp:(.text+0x260):对‘WebServer::eventListen()’未定义的引用 main.cpp:(.text+0x26f):对‘WebServer::eventLoop()’未定义的引用 main.cpp:(.text+0x283):对‘WebServer::~WebServer()’未定义的引用 main.cpp:(.text+0x36f):对‘WebServer::~WebServer()’未定义的引用 collect2: error: ld returned 1 exit status

Astronaut-diode commented 1 year ago

应该是缺了链接库的信息,比如lpthread这些。

meiony commented 1 year ago

你不是直接sh ./build.sh打包编译的吗?为什么要单独编译main文件嘞

SignedWhiskeyXD commented 1 year ago

了解过Makefile吗? 请在终端make server,这会根据Makefile内的规则进行编译,整个项目远不止有main.cpp一个源文件