简体   繁体   中英

How to configure Boost with Netbeans 6.9 on Ubuntu

I have gcc 4.4.5 and the latest boost library. I want to use boost specifically for its regex library. I tried using the built in c++ regex functions but apparently they are not fully functional yet. I followed a tutorial online to set up netbeans.

I added /usr/include/boost to the c++ code assistance include directories. I then added -lboost_regex-mt to the build>linker>additional options area in the project configuration. but I still get this error:

/usr/bin/ld: cannot find -lboost_regex-mt
collect2: ld returned 1 exit status

This is the command thats being created by netbeans:

g++ -lboost_regex-mt -o dist/Debug/GNU-Linux-x86/examples01 build/Debug/GNU-Linux-x86/main.o  

I also tried doing it with -lboost-regex and -lboost-regex-st and the same error, with only the mt changed. I also tried running a file using regex objects through the terminal but still got the same error. Can anyone help with this problem? Or at least point me in the right direction?

You have to set your project's "Additional Library Directories" so that it knows what other directories to look into for your libraries to link against.

Here's a screenshot from Netbeans' site here: http://netbeans.org/community/magazine/html/03/c++/

替代文字

edit: note that this will affect the generated compiler command to have -L options which specify additional locations to look for library files.

You need to tell g++ where to find the libraries. One way doing this is to append the location of boost's libraries to your LD_LIBRARY_PATH . Note that this is not the same as the header files (the .hpp files in the include directory) which you said you've already included in your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM