当前位置: 代码迷 >> Solaris >> Solaris 10 x86虚拟机上编译动态连接库的有关问题
  详细解决方案

Solaris 10 x86虚拟机上编译动态连接库的有关问题

热度:3605   发布时间:2013-02-26 00:00:00.0
Solaris 10 x86虚拟机下编译动态连接库的问题
solaris 10x86 u6、虚拟机环境下编译动态连接阿库的问题:

c/c++代码为:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <unistd.h>

int abc(int a, int b)
{
    return a + b;
}

int my_socket()
{
    return socket(PF_INET, SOCK_STREAM, 0);
}


编译命令行:
gcc -shared -o 123.so 123.cpp -lsocket -lnsl

编译结果:
文本重定位持续                                  引用的
    针对符号                位移        在文件中
__xnet_socket                       0x1c        /var/tmp//cchdeuju.o
ld: 致命的: 重定位仍旧与可分配但不可写的节相反
collect2: ld returned 1 exit status


请问改如何解决,谢谢了

------解决方案--------------------------------------------------------
http://bbs2.chinaunix.net/viewthread.php?tid=946354
参考这个
------解决方案--------------------------------------------------------
gcc -fPIC -c 123.c

gcc -shared -o 123.so 123.o