在AIX上使用gcc编译c时出错

在AIX上使用gcc编译c时出错,c,gcc,aix,C,Gcc,Aix,我试图在aix上使用gcc构建一个简单的c应用程序 gcc -I. -c hello.c -o hello.o gcc -o helloWorld hello.o -L helloHelper.so -ldl 我得到以下错误 ld 0711-317 ERROR: Undefined symbol: .PrintHello PrintHello是helloHelper库中的一个方法 我可以在windows中构建应用程序。尝试以下操作: gcc -o helloworld hello.o -L.

我试图在aix上使用gcc构建一个简单的c应用程序

gcc -I. -c hello.c -o hello.o
gcc -o helloWorld hello.o -L helloHelper.so -ldl
我得到以下错误

ld 0711-317 ERROR: Undefined symbol: .PrintHello
PrintHello是helloHelper库中的一个方法

我可以在windows中构建应用程序。

尝试以下操作:

gcc -o helloworld hello.o -L. -lhelloHelper -ldl

选项
-L
用于指示搜索库的目录。要直接链接动态库,只需将其放入linker命令中:

gcc -o helloWorld hello.o helloHelper.so -ldl

另一种选择是使用
-lhelloHelper
,但是这个库应该被称为
libhelloHelper。在我的回答中遗漏了这一点。