再AIX上开发动态库的问题

hupo1982 2008-10-15 10:24:22
我在AIX8上编译一个动态库,使用了一个cpp文件和一个fortran文件:
My cpp code is:
/*****************************************************/
/* main1.cpp */
/*****************************************************/
#include <stdio.h>
#include <stdlib.h>

#define hupotest HUPOTEST
extern "C" void hupotest();

extern "C" int main1()
{
printf("Cpp function display!\n");
hupotest();
return 1;
}

/* end of main1.cpp */


My fortran code is:
/*****************************************************/
/* mainf.f */
/*****************************************************/
SUBROUTINE HUPOTEST()

WRITE(*,*) 'Fortran function display!'
RETURN
END

/* end of mainf.f */


我是这样建立动态库的:
xlc -c main1.cpp
xlf -c mainf.f
xlc -o libtest.so -G main1.o mainf.o


然后我做了一个可执行程序去调用这个动态库里面的函数(使用dlopen和dlsym), 当我调用cpp里面的mian1函数时,我遇到了一个错误:
"Cpp function display!"
"Illegal instruction(core dumped)"
那位高手有过这方面的经验,给小弟指点一二,多谢。
是不是我动态库做的方法有问题?
...全文
100 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
once_and_again 2008-10-20
  • 打赏
  • 举报
回复
动态库,
就是 二进制 代码接口
hupo1982 2008-10-19
  • 打赏
  • 举报
回复
再顶一下
hupo1982 2008-10-16
  • 打赏
  • 举报
回复
没人知道吗?
Discuz论坛AIX环境配置 主机系统:AIX5.3 数据库:Mysql5 WEB服务:Apache2+PHP5 准备: gcc V4.0.0 for AIX V5.3 (gcc-4.0.0-1.aix5.3.ppc.rpm) gcc-c++ V4.0.0 for AIX V5.3 (gcc-cplusplus-4.0.0-1.aix5.3.ppc.rpm) libgcc V4.0.0 for AIX V5.3 (libgcc-4.0.0-1.aix5.3.ppc.rpm) libstdc++ V4.0.0 for AIX V5.3 (libstdcplusplus-4.0.0-1.aix5.3.ppc.rpm) libstdc++-devel V4.0.0 for AIX V5.3 (libstdcplusplus-devel-4.0.0-1.aix5.3.ppc.rpm) bzip v1.0.2 (bzip2-1.0.2-3.aix5.1.ppc.rpm) expat v1.95.7 (expat-1.95.7-4.aix5.1.ppc.rpm) flex v2.5.4a (flex-2.5.4a-6.aix4.3.ppc.rpm) freetype2 v2.1.7 (freetype2-2.1.7-5.aix5.1.ppc.rpm) libjpeg v6b (libjpeg-6b-6.aix5.1.ppc.rpm) libpng v1.2.8 (libpng-1.2.8-5.aix5.1.ppc.rpm) zlib v1.2.3 (zlib-1.2.3-3.aix5.1.ppc.rpm) libxml2-2.6.21-4.aix5.2.ppc.rpm libxml2-devel-2.6.21-4.aix5.2.ppc.rpm pkg-config-0.19-6.aix5.2.ppc.rpm 安装 AIX 分发版中的 Base Application Development Math Library (bos.adt.libm) httpd-2.2.15.tar.gz php-5.2.11.tar mysql-5.1.46-aix5.3-powerpc.tar AIX5.3安装Mysql5 cd /usr/mysql # ./scripts/mysql_install_db Installing MySQL system tables... OK Filling help tables... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: ./bin/mysqladmin -u root password 'new-password' ./bin/mysqladmin -u root -h testos password 'new-password' Alternatively you can run: ./bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd . ; ./bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd ./mysql-test ; perl mysql-test-run.pl Please report any problems with the ./bin/mysqlbug script! AIX5.3安装Apache (httpd2.2.15 ) #./configure --prefix=/usr/local/apache --enable-mods-shared=all --enable-so (/usr/local/apache为安装目录) #make #make install 配置httpd.conf vi /usr/local/apache/conf/httpd.conf ServerName 配置为 127.0.0.1,服务器IP或域名 DirectoryIndex 中添加index.htm index.jsp default.htm default.html Group nobody 必须要改,否则apache不能启动 #cd /usr/local/apache/bin #./apachectl start 编辑apache配置文件httpd.conf 找到LoadModule php5_module modules/libphp5.so 前面的#号去掉(默认已去掉注释) 还有找到DirectoryIndex index.html 加上 index.php index.htm AIX5.3安装PHP ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-zlib #/opt/freeware/bin/make # cp .libs/libphp5.so /usr/local/apache2/modules # cp php.ini-recommended /usr/local/apache2/conf/php.ini 不需要make install

23,217

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧