C++ 未定义的对“u_fopen_48'”的引用;

C++ 未定义的对“u_fopen_48'”的引用;,c++,c,icu,C++,C,Icu,我是c/c++新手,我想我有一些基本问题。编译时,我得到了对u\u fopen\u 48'的未定义引用错误: #include <unicode/ustdio.h> int main(int argc, char** argv) { UFILE* ufile = u_fopen("/home/emstol/Desktop/utf8demo.txt", "r", NULL, "utf8"); return 0; } 你好像忘了链接你用过的图书馆。有关说明,请参阅 在

我是c/c++新手,我想我有一些基本问题。编译时,我得到了对u\u fopen\u 48'的
未定义引用
错误:

#include <unicode/ustdio.h>

int main(int argc, char** argv) {
    UFILE* ufile = u_fopen("/home/emstol/Desktop/utf8demo.txt", "r", NULL, "utf8");
    return 0;
}

你好像忘了链接你用过的图书馆。有关说明,请参阅

在构建复合项目时,编译器不能简单地找到它所需的所有引用。大多数库都是以共享对象文件(.so)的形式出现的,它们的C代码不会与项目的其余部分一起编译,而只为它们的函数提供头。这允许编译器在代码中为要放入的函数创建“套接字”,但不告诉链接器这些函数应该从何处获取-链接过程将失败。
因此,您必须明确告诉链接器在何处搜索它将要搜索的符号,这通常是通过
-l
标志完成的,尽管看起来ICU库采取了某种不同的方法。

正确!谢谢你的快速回答+1给你。
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: Entering directory `/home/emstol/NetBeansProjects/TextFairy1'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/textfairy1
make[2]: Entering directory `/home/emstol/NetBeansProjects/TextFairy1'
mkdir -p dist/Debug/GNU-Linux-x86
g++     -o dist/Debug/GNU-Linux-x86/textfairy1 build/Debug/GNU-Linux-x86/main.o  
build/Debug/GNU-Linux-x86/main.o: In function `main':
/home/emstol/NetBeansProjects/TextFairy1/main.cpp:4: undefined reference to `u_fopen_48'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/GNU-Linux-x86/textfairy1] Error 1
make[2]: Leaving directory `/home/emstol/NetBeansProjects/TextFairy1'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `/home/emstol/NetBeansProjects/TextFairy1'
make: *** [.build-impl] Error 2