a***e 发帖数: 1140 | 1 目的: 把C++ code + solaris JDK 移植到 RH9 上.
过程: 源程序 在 solaris 下编译成功. 用的是命令:
g++ -G -I/JDK-path/include -I/JDK-path/solaris source.c -o dest.so
然后, 先在 RH9下安装了SDK1.4, 用的是同样的命令, 出错了,出错信息是:
"-G" is not recognized by g++
XXXXX, undefined reference to 'main'
collect2: 1d return 1 exit status
分析: 将命令换成 "-g", 还是一样. 查了g++ 在 linux 的manual,都没有-G选项.可是
"-G" 命令可以在solaris下执行,不能在linux下执行. 如果在solaris下不用-G选项,出错
信息和linux下一样.
solaris下JDK1.2
哪位高人给指点指点. 怎样解决? | t****g 发帖数: 1 | 2 -G is used to generate shared object (check g++ manual for solaris, yes
they are different). It's for compatibility, you should use -shared.
Actually .c should be compiled to .o first, then link to .so. I think
-G is passed to linker in link stage; in compile stage, it actually
means -fPIC or something similar to generate relocatable objects.
So in linux you should use
g++ -fPIC -Ixxxx -Ixxxx source.c -o source.o
g++ -shared source.o -o dest.so
【在 a***e 的大作中提到】 : 目的: 把C++ code + solaris JDK 移植到 RH9 上. : 过程: 源程序 在 solaris 下编译成功. 用的是命令: : g++ -G -I/JDK-path/include -I/JDK-path/solaris source.c -o dest.so : 然后, 先在 RH9下安装了SDK1.4, 用的是同样的命令, 出错了,出错信息是: : "-G" is not recognized by g++ : XXXXX, undefined reference to 'main' : collect2: 1d return 1 exit status : 分析: 将命令换成 "-g", 还是一样. 查了g++ 在 linux 的manual,都没有-G选项.可是 : "-G" 命令可以在solaris下执行,不能在linux下执行. 如果在solaris下不用-G选项,出错 : 信息和linux下一样.
|
|