如何在远程主机上使用 GNU 在 Netbeans7.1.1 中编译 C/C++
How to compile C/C++ in Netbeans7.1.1 with GNU on remote host
我已经安装了连接到远程构建主机(我的虚拟盒子)的 Netbeans 7.1.1。我试图编译我在某些网站上找到的一些程序。
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
// Appelée à la rencontre de chaque balise ouvrante
void debut_element(void *user_data, const xmlChar *name, const xmlChar **attrs) {
printf("Début de l'élément : %sn", name);
}
int main() {
// Initialisation à zéro de tous les membres (NULL pour un pointeur par conversion)
xmlSAXHandler sh = { 0 };
// Affectation des fonctions de rappel
sh.startElement = debut_element;
xmlParserCtxtPtr ctxt;
// Création du contexte
if ((ctxt = xmlCreateFileParserCtxt("catalogue.xml")) == NULL) {
fprintf(stderr, "Erreur lors de la création du contexten");
return EXIT_FAILURE;
}
// Fonctions de rappel à utiliser
ctxt->sax = &sh;
// Analyse
xmlParseDocument(ctxt);
// Le document est-il bien formé ?
if (ctxt->wellFormed) {
printf("Document XML bien formén");
} else {
fprintf(stderr, "Document XML mal formén");
xmlFreeParserCtxt(ctxt);
return EXIT_FAILURE;
}
// Libération de la mémoire
xmlFreeParserCtxt(ctxt);
return EXIT_SUCCESS;
}
但是,我在编译过程中收到此错误消息
Copying project files to /home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/ at saebyuk@redHat
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
gmake[1]: Entering directory `/home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/C/Users/saebyuk/Documents/NetBeansProjects/xml_decoder_Red_hat'
"/usr/bin/gmake" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/xml_decoder_red_hat
gmake[2]: Entering directory `/home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/C/Users/saebyuk/Documents/NetBeansProjects/xml_decoder_Red_hat'
gmake[2]: Warning: File `main.cpp' has modification time 2.1e+04 s in the future
mkdir -p build/Debug/GNU-Linux-x86
rm -f build/Debug/GNU-Linux-x86/main.o.d
g++ -c -g -Wall -I/usr/include/libxml2 -MMD -MP -MF build/Debug/GNU-Linux-x86/main.o.d -o build/Debug/GNU-Linux-x86/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux-x86
g++ -I/usr/include/libxml2 -o dist/Debug/GNU-Linux-x86/xml_decoder_red_hat build/Debug/GNU-Linux-x86/main.o
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/C/Users/saebyuk/Documents/NetBeansProjects/xml_decoder_Red_hat/main.cpp:35: undefined reference to `xmlCreateFileParserCtxt'
/home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/C/Users/saebyuk/Documents/NetBeansProjects/xml_decoder_Red_hat/main.cpp:40: undefined reference to `xmlParseDocument'
/home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/C/Users/saebyuk/Documents/NetBeansProjects/xml_decoder_Red_hat/main.cpp:46: undefined reference to `xmlFreeParserCtxt'
collect2: ld returned 1 exit status
gmake[2]: *** [dist/Debug/GNU-Linux-x86/xml_decoder_red_hat] Error 1
gmake[2]: Leaving directory `/home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/C/Users/saebyuk/Documents/NetBeansProjects/xml_decoder_Red_hat'
gmake[1]: *** [.build-conf] Error 2
gmake[1]: Leaving directory `/home/saebyuk/.netbeans/remote/redHat/saebyuk-pc-Windows-x86/C/Users/saebyuk/Documents/NetBeansProjects/xml_decoder_Red_hat'
gmake: *** [.build-impl] Error 2
我知道这已经在这里被问了数千次,但我找不到正确的答案。如果你们中的任何人可以指导我,我将不胜感激,因为我是这方面的新手。
我不知道如何配置 Netbeans;但是如果您手动执行以下命令,您的代码编译起来不会有问题:
gcc -o xmltest xmltest.c -I /usr/include/libxml2 -lxml2
如果您还没有Makefile
,这是一个好的开始:
LDFLAGS := -I /usr/include/libxml2 -lxml2
但是,如果 Netbeans 强制您使用不同的构建系统,则必须找出另一种方法来适当地设置链接器选项。
libxml2 库位于 libxml2/libxml/* 下,但所有头文件都使用 libxml/*。
将指令更改为
#include <libxml2/libxml/*>
也会抱怨,因为所有指令都指向同一个文件夹;我在远程服务器上所做的一个解决方法是创建一个符号链接,指向包含文件夹下的库。
Debian Lenny 在 ARM 板上...
ln -s /usr/include/libxml2/libxml /usr/include/libxml
重新启动 Netbeans,所有红色都消失了,构建成功并成功运行。
相关文章:
- 使用 Powershell 命令将 cpp 文件的文件夹编译为 GNU 的 g++
- 如何使用 gnu gcc 标志 -mpc32、-mpc64 和 -mpc80?
- 防止 GNU Make 在每次构建时生成 protobuf 代码
- 为什么 C++ 编译器在"c:program filesgnu emacsinclude"中查找包含文件?
- 有没有适用于Windows.lib文件的GNU二进制文件描述符(BFD)
- 监视GNU Radio中的缓冲区
- GNU C++: unique_ptr.h 没有这样的文件或目录
- MinGW在Cygwin上.关于链接GNU科学图书馆的一些问题
- 与libc相比,Gnu科学图书馆的性能较差
- GNU 在看到其他同名文件时重用源文件
- 从 C++ 调用 GNU 绘图,无需用户输入
- 如何为GSL(GNU科学库)调整C++式随机数引擎?
- 没有规则来设定目标'/usr/lib/x86_64-linux-gnu/libboost_filesystem.so'
- 使用 PYbombs 安装软件包 GNU 无线电时出错
- 在编译时使用 gnu++11 过滤值列表,不使用 stdlib(Arduino 环境)
- Java System.loadLibrary 不会在 /usr/lib/x86_64-linux-gnu/ 文件夹中查
- 在Windows中构建GSL(GNU科学库)以与VS2015一起使用
- _mm512_exp_pd与 GNU 编译器一起使用
- GNU Radio中基于条件的输出的块类型
- 如何在远程主机上使用 GNU 在 Netbeans7.1.1 中编译 C/C++