[C++书籍] 学习ACE遇到问题
nj_first
2010-02-23
//#include <stdlib.h>
//#include <stdio.h> #include <iostream> using namespace std; #include <ace/INET_Addr.h> #include <ace/SOCK_Connector.h> #include <ace/SOCK_Stream.h> #include <ace/SOCK_IO.h> /* * */ int main(int argc, char** argv) { // printf("Hello world!\n"); ACE_INET_Addr address("127.0.0.1:7777"); ACE_SOCK_Connector connector; ACE_SOCK_Stream stream; if(connector.connect(stream,address) == -1) { cout<<strerror(errno)<<endl; } return (EXIT_SUCCESS); } 出现如下错误 /usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf make[1]: 正在进入目录 `/home/aaa/NetBeansProjects/CppApplication_1' /usr/bin/make -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/cppapplication_1 make[2]: 正在进入目录 `/home/aaa/NetBeansProjects/CppApplication_1' mkdir -p dist/Debug/GNU-Linux-x86 g++ -o dist/Debug/GNU-Linux-x86/cppapplication_1 build/Debug/GNU-Linux-x86/main.o -L/usr/lib build/Debug/GNU-Linux-x86/main.o: In function `main': /home/aaa/NetBeansProjects/CppApplication_1/main.cpp:23: undefined reference to `ACE_INET_Addr::ACE_INET_Addr(char const*, int)' /home/aaa/NetBeansProjects/CppApplication_1/main.cpp:27: undefined reference to `ACE_Addr::sap_any' /home/aaa/NetBeansProjects/CppApplication_1/main.cpp:27: undefined reference to `ACE_SOCK_Connector::connect(ACE_SOCK_Stream&, ACE_Addr const&, ACE_Time_Value const*, ACE_Addr const&, int, int, int, int)' /home/aaa/NetBeansProjects/CppApplication_1/main.cpp:32: undefined reference to `ACE_INET_Addr::~ACE_INET_Addr()' /home/aaa/NetBeansProjects/CppApplication_1/main.cpp:32: undefined reference to `ACE_INET_Addr::~ACE_INET_Addr()' build/Debug/GNU-Linux-x86/main.o: In function `ACE_SOCK_IO': /usr/include/ace/SOCK_IO.inl:12: undefined reference to `ACE_SOCK::ACE_SOCK()' collect2: ld returned 1 exit status make[2]: *** [dist/Debug/GNU-Linux-x86/cppapplication_1] 错误 1 make[2]:正在离开目录 `/home/aaa/NetBeansProjects/CppApplication_1' make[1]: *** [.build-conf] 错误 2 make[1]:正在离开目录 `/home/aaa/NetBeansProjects/CppApplication_1' ation_f 新手,请指点。 |
|
athxy
2010-03-27
看这条信息:collect2: ld returned 1 exit status
很显然是连接阶段错误,一般是找不到库文件: 您可以尝试直接编译: g++ -oclient client.cpp -lACE 以上假设您的可执行文件名:client,源文件:client.cpp,关键是要连接ACE库 |
|
nj_first
2010-03-28
Thank you!
|