2012-07-04 136 views
2

我已经将一个C++代码从一个开放的solaris操作系统移植到了Redhat 4操作系统。在此代码段IAM正在一个错误:无效的精灵标题linux

AsciiFileName = new char [1024]; 
    cout<<"HandleFile is getting called "<<endl; 
    /// Converting the file name to ascii. 
    FileName += strFileName; 
    FileName.ConvertToAscii(AsciiFileName); 

    /// Get handle to the shared object file. 
    Handle = dlopen(AsciiFileName, RTLD_LOCAL | RTLD_LAZY); 
    cout<<"Handle = dlopen(AsciiFileName, RTLD_LOCAL | RTLD_LAZY); is getting called AsciiFileName"<<AsciiFileName<<endl; 
    if (!Handle) 
    { 
    cout<<"Handle is NULL"<<endl; 
    cout<<dlerror()<<endl; 
exit(EXIT_FAILURE); 

我得到的错误是:

invalid elf header linux 

这是不能够打开,以便file.Here是相关的日志,它

Before ProcessSharedObject->IterateOnDir 
GCVDirectoryIterator::IterateOnDir:file name :/bin/ls /trnuser1/rmtrain/DevelopmentEnv/Telstra/USM/dat/CnEModules/*.so 
GCVDirectoryIterator::IterateOnDir:file opened :/trnuser1/rmtrain/DevelopmentEnv/Telstra/USM/dat/CnEModules/libGCVCore.so 

before GCVDirectoryIterator::AddFile 
HandleFile is getting called 
Handle = dlopen(AsciiFileName, RTLD_LOCAL | RTLD_LAZY); is getting called AsciiFileName/trnuser1/rmtrain/DevelopmentEnv/Telstra/USM/dat/CnEModules/libGCVCore.so 
Handle is NULL 
/trnuser1/rmtrain/DevelopmentEnv/Telstra/USM/dat/CnEModules/libGCVCore.so: invalid ELF header 
+0

您是否正在尝试打开solaris .so? –

+0

不,它是红帽所以文件 – subodh1989

回答

2

/trnuser1/rmtrain/DevelopmentEnv/Telstra/USM/dat/CnEModules/libGCVCore.so:当前AR存档

这是一个静态库(存档),而应该是.a,不.so。你不能用dlopen打开它。

+0

这是正确的。我看到在编译过程中显示“ ADD_LIBRARY用于库GenericUSMModules与SHARED选项一起使用,但目标平台仅支持STATIC库,建立了 它是STATIC 。这可能会导致问题。 “。感谢您的帮助 – subodh1989

0

您可能已将libGCVCore.so从Solaris机器复制到RedHat机器。 Solaris机器很可能具有与RedHat不同的体系结构(Sparc?)。你可以有一个确认的打字:

file libGCVCore.so 

该命令应打印你正在尝试链接库的目标架构信息。

+0

不,所有需要的库在编译期间在这里创建。这些不会被复制。 – subodh1989

+0

此命令显示:/trnuser1/rmtrain/DevelopmentEnv/Telstra/USM/dat/CnEModules/libGCVCore.so:current ar archive – subodh1989

+0

这有点奇怪,输出实际上应该声明文件是一个共享对象,动态链接,并且目标体系结构(例如:x86-64) – Sdra