gpt4 book ai didi

c++ - 配置 Netbeans 以调试包含非标准库的 C++ 程序

转载 作者:太空宇宙 更新时间:2023-11-04 04:36:34 25 4
gpt4 key购买 nike

我想使用非标准库 ( igraph C library ) 使用 Netbeans 在 C++ 中构建一个“hello world”程序。

我也想使用 Netbeans 的调试功能。

首先我跟着安装instructions provided by the library vendor , 使用终端编译和运行 a hello world program supplied by library vendor .它使用终端编译和运行良好。

问题是当我在 Netbeans 中打开 C 项目文件时,我必须配置它以便它可以:

  1. 运行程序
  2. 调试程序

如果您使用 Netbeans 的标准库,您可以立即运行和调试 C++ 程序。但是我在一些论坛上看到,如果我想让 Netbeans 运行和调试包含非标准库的 C++ 程序,需要进行一些配置

最佳答案

我找到了答案。以下是步骤:

<强>1。找出您的非标准库文件的安装位置

在我的 Ubuntu 上,我使用以下命令找出我安装的文件的位置:

pkg-config --libs --cflags igraph

在上面的命令中,您必须将 igraph 替换为您安装的非标准库的名称。

这个命令给了我以下输出:

-I/usr/local/include/igraph  -L/usr/local/lib -ligraph

我记下了-I之后的路径,-L之后的路径和-l之后的字符串。这 3 个需要按照以下步骤在 Netbeans 中提供

来源:http://igraph.org/c/doc/igraph-tutorial.html#idm470953198960

<强>2。配置 Netbeans

Right click on Project in Netbeans -> properties -> Linker ->Libraries -> Add option -> Other -> type -ligraph in here

在您的情况下,您必须在步骤 #1 中键入您在系统上找到的内容而不是 -ligraph

Project -> properties -> Linker -> Additional Library Directories > I typed /usr/local/lib in here

在您的情况下,您必须使用在步骤 #1 中的 -L 标志之后在系统上获得的路径

Project -> properties -> C++ Compiler -> Include Directories -> I typed /usr/local/include/igraph in here

在您的情况下,您必须使用在步骤 #1 中的 -I 标志之后在系统上获得的路径

来源:https://stackoverflow.com/a/13292276/3143538

添加到项目->属性->运行->环境:

Name: LD_LIBRARY_PATH
Value: $LD_LIBRARY_PATH:/usr/local/lib

而不是 /usr/local/lib 你必须使用你在步骤 #1 中的 -L 标志之后得到的路径

来源:https://askubuntu.com/questions/267071/ld-library-path-specification

经过以上步骤,我可以编译、运行和调试程序了

关于c++ - 配置 Netbeans 以调试包含非标准库的 C++ 程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30117163/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com