首页 文章

C通过Netbeans远程开发在Linux上进行升级:对boost :: filesystem :: path :: codecvt()的未定义引用

提问于
浏览
0

所以我在windows7上安装了Netbeans并配置了带有samba的Ubuntu盒子来共享我有源代码和boost库的开发目录 . 我编译了boost库以便能够链接到boost_filesystem但是当我尝试编译应用程序时仍然遇到此错误:

Copying project files to /home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/ at nms@ophelia.tele2.net
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/mr_deamon
make[2]: Entering directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-     Windows-x86_64/Z/mr_deamon'
mkdir -p build/Debug/GNU-Linux-x86
rm -f "build/Debug/GNU-Linux-x86/mr_deamon.o.d"
g++    -c -g -I/opt/mail-relay/mr_deamon/boost_1_55_0 -I/opt/mail-relay/mr_deamon/mysql_connector_cpp/include -MMD -MP -MF "build/Debug/GNU-Linux-x86/mr_deamon.o.d" -o build/Debug/GNU-Linux-x86/mr_deamon.o mr_deamon.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/mr_deamon build/Debug/GNU-Linux-x86/mr_deamon.o -L/opt/mail-relay/mr_deamon/mysql_connector_cpp/lib -L/opt/mail-relay/mr_deamon/boost_1_55_0/bin.v2/libs -lmysqlcppconn-static -lmysqlclient -lboost_system -lboost_filesystem
build/Debug/GNU-Linux-x86/mr_deamon.o: In function `boost::filesystem::file_size(boost::filesystem::path const&)':
/opt/mail-relay/mr_deamon/boost_1_55_0/boost/filesystem/operations.hpp:447: undefined reference to `boost::filesystem::detail::file_size(boost::filesystem::path const&,   boost::system::error_code*)'
build/Debug/GNU-Linux-x86/mr_deamon.o: In function `path<char*>':
/opt/mail-relay/mr_deamon/boost_1_55_0/boost/filesystem/path.hpp:139: undefined reference to `boost::filesystem::path::codecvt()'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/mr_deamon] Error 1
make[2]: Leaving directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/nms/.netbeans/remote/ophelia.tele2.net/t2003915-Windows-x86_64/Z/mr_deamon'
make: *** [.build-impl] Error 2


BUILD FAILED (exit value 2, total time: 2s)

我以为我得到了连接权 . 这是程序代码:

#include <iostream>
#include <boost/filesystem.hpp>
//using namespace std;
using namespace boost::filesystem;
int main(int argc, char**argv)
{
    std::cout << file_size(argv[0]);

    return EXIT_SUCCESS;
}

sql部分适用于链接和所有,但只包括boost文件系统足以获得构建错误,无法获得如何使用Windows上的netbeans远程开发到Linux . 我究竟做错了什么?

一个没有netbeans的新尝试,只是在Ubuntu上使用来自Boost filesystem link的示例...并且使用编译命令:g -pthread mr.cpp -lboost_filesystem-mt -lboost_system-mt输出为/tmp/ccIZaqeX.o:In function boost::filesystem::file_size(boost::filesystem::path const&)': mr.cpp: (.text._ZN5boost10filesystem9file_sizeERKNS0_4pathE[boost::filesystem::file_size(boost::filesystem::path const&)]+0x19): undefined reference to boost :: filesystem :: detail :: file_size(boost :: filesystem :: path const&,boost :: system :: error_code *)'/ tmp / ccizaqeX.o:在函数 boost::filesystem::path::path<char*>(char* const&, boost::enable_if<boost::filesystem::path_traits::is_pathable<boost::decay<char*>::type>, void>::type*)': mr.cpp: (.text._ZN5boost10filesystem4pathC2IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE[_ZN5boost10filesystem4pathC5IPcEERKT_PNS_9enable_ifINS0_11path_traits11is_pathableINS_5decayIS4_E4typeEEEvE4typeE]+0x22): undefined reference to boost :: filesystem :: path :: codecvt()'collect2:ld返回1退出状态

我不明白..

2 回答

  • 1

    我昨天遇到了同样的问题:

    我怎么解决:

    首先:如果您按源安装了Boost,请确保将其编译为您在netbeans中使用的正确编译器工具集 . 例如,我用MinGW @ Windows 8 Boost/MingW进行了测试 .

    第二:在Netbeans(我使用7.4版本)中,我手动添加了我想要的库:

    项目属性>链接器>库>添加库>选择.a文件 .

    编辑:

    这个链接可能很有用:undefined reference with boost when I try to compile

  • 1

    太棒了,所以最后它起作用了,这就是我所做的:1-安装gcc 4.8(不确定这是否相关) . 2-下载并解压缩到/ usr / local 3- run bootstrap.sh 4-将project-config.jam中的toolset参数修改为使用gcc:4.8.1:g -4.8; 5-运行./b2 --with-system 6-运行./b2 --with-filesystem步骤5和6都是用户root完成的 . 7-像这样编译源文件:

    # g++-4.8 mr.cpp -L /usr/local/boost_1_55_0/stage/lib -I /usr/local/boost_1_55_0 -lboost_system -lboost_filesystem -o mr
    

    Jee,最后,我离开Boost几分钟 .

    我认为有所不同的是编译器(工具集)和安装路径的一致性,特别是那两个“-L / usr / local / boost_1_55_0 / stage / lib -I / usr / local / boost_1_55_0”

相关问题