免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2916 | 回复: 4
打印 上一主题 下一主题

[C++] 江湖救急: C++编译问题紧急求救 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-06-15 05:20 |只看该作者 |倒序浏览
公司一个人走了,他的程序让我接手,我不是程序员,不熟悉编程,我要做的是把他写好的程序在LINUX中编译好可以运行就可以了。当时他交给我的时候源程序是装在Fedora Core 5上的,还编译了一次给我看,当时没有显示错误信息。后来我把这个程序COPY到一个RedHat机器上编译过也没出问题(那台RedHat的机器走的那位在上面工作过)。

现在需要把程序放到一台Debian的服务器上运行,把手里的源程序全部COPY到Debian上编译,出现如下错误:

g++ -DHAVE_CONFIG_H -I. -Icommoncpp2-1.1.0/include       -D_REENTRANT -D_THREAD_SAFE -g -DDEBUG -c srvmgrd.cpp
commoncpp2-1.1.0/include/cc++/string.h:89: error: ISO C++ forbids declaration of "MemPager" with no type
commoncpp2-1.1.0/include/cc++/string.h:89: error: expected ';' before '*' token
commoncpp2-1.1.0/include/cc++/thread.h:917: error: using typedef-name 'ost::Thread::Cancel' after 'enum'
commoncpp2-1.1.0/include/cc++/thread.h:892: error: 'ost::Thread::Cancel' has a previous declaration here
commoncpp2-1.1.0/include/cc++/thread.h: In member function 'ost::Thread::Cancel ost::Thread::getCancel()':
commoncpp2-1.1.0/include/cc++/thread.h:1195: error: invalid conversion from 'int' to 'ost::Thread::Cancel'
commoncpp2-1.1.0/include/cc++/socket.h: At global scope:
commoncpp2-1.1.0/include/cc++/socket.h:136: warning: inline function 'virtual void ost::InetMcastAddrValidator:perator()(in_addr) const' used but never defined
make: *** [srvmgrd.o] Error 1

上面提示错误的相关文件和其中提示错误的附近几行内容如下:

------------------------------------
string.h

private:
        friend class MemPager;

        static MemPager *pager;      <==== this is line 89
        static char **idx;
---------------------------------------

------------------------------------------
thread.h

        typedef enum Cancel
        {
                cancelInitial=0,  /**< used internally, do not use */
                cancelDeferred=1, /**< exit thread on cancellation pointsuch as yield */
                cancelImmediate,  /**< exit befor cancellation */
                cancelDisabled,   /**< ignore cancellation */
                cancelManual,     /**< unimplemented (working in progress)
                                            @todo implement */
                cancelDefault=cancelDeferred
                        /**< default you should use this for compatibility instead of deferred */
        } Cancel;    <==== this is line 892


private:
       
        Thread *_parent;
        enum Cancel _cancel;             <==== this is line 917
        Semaphore *_start;


        inline Cancel getCancel(void)
                {return _cancel;};     <=== this is line 1195
--------------------------------------------

---------------------------------------
socket.h

        inline void
        operator()(const in_addr address) const;   <=== this is line 136
---------------------------------------


我把源程序再COPY到另外两台运行Fedora的服务器上(分别装的是Fedora Core 6和Fedora Core 5)试验,还是出现同样的错误。

急求各位帮助判断错误出在什么地方以及如何处理。用GOOGLE搜索出来的信息都是程序写得有问题,但这个源程序我在原来那台Fedora Core 5以及RedHat上编译都没问题。

谢谢。

论坛徽章:
0
2 [报告]
发表于 2007-06-15 08:26 |只看该作者
仔细检查可正常编译和不能正常编译的系统的编程环境,找出差异

至于说string.h的第89行的错误,这个类MemPager是 GNU的一个通用类,所以不是真正的错误,真正的错误可能在于使用它的代码。
http://www.gnu.org/software/comm ... lass_mem_pager.html

论坛徽章:
0
3 [报告]
发表于 2007-06-15 10:46 |只看该作者
g++ 的版本问题吧??猜的

论坛徽章:
0
4 [报告]
发表于 2007-06-18 23:55 |只看该作者

回复 3楼 baohuaihuai 的帖子

查了原来能成功编译的系统中g++是装了GCC-3.3.6,另外还有随Fedora Core 5安装的GCC 4.0.0,现在想把另外一台Fedora Core 6装上GCC-3.3.6来测试是否g++版本问题,竟然GCC-3.3.6装不上,出来一大堆ERROR。在同一台Fedora Core 6上装新的GCC-4.1.2就没有问题,但是用这个新装的GCC-4.1.2试图编译第一个帖子里说的自己的程序,结果还和没装GCC-4.1.2以前一样。

请各位帮忙看看可能的问题和解决方法,谢谢。

论坛徽章:
0
5 [报告]
发表于 2007-06-19 13:47 |只看该作者
感觉是commoncpp的版本的问题,1.1.0这个版本太低了,现在已经到1.5.x版本了,你用你的系统的包管理工具检查一下有没有commoncpp的升级版本,用g++4编译早期版本的程序也太难为编译器了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP