您的位置:首页 > 编程语言

MinGW中G++编译简单代码时--enable-auto-import问题

2010-09-29 16:27 501 查看
今天下载了MinGW试用了一下

写了下个c++代码

helloworld.cc

 

#include <iostream>
#include "stime.h"
int main(){
Time t;
PTime pt=&t;
pt->hour=1;
pt->minute=3;
pt->second=6;
std::cout<<"Hello World"<<std::endl;
std::cout<<pt->hour<<pt->minute<<pt->second;
return 0;
}


stime.h的内容如下

//stime.h
typedef int HOUR;
typedef int MINUTE;
typedef int SECOND;
typedef struct STime{
HOUR hour;
MINUTE minute;
SECOND second;
}Time,*PTime;


 

用最简单的g++ helloword.cc,编译成功但得到这些提示

Info: resolving std::cout  by linking to __imp___ZSt4cout (auto-import)

c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: warning: a

uto-importing has been activated without --enable-auto-import specified on the c

ommand line.

This should work unless it involves constant data structures referencing symbols

 from auto-imported DLLs.

后来从网上找了一下原来用参数可以解决,

 

g++ -Wl,--enable-auto-import helloworld.cc -o helloword

 

好了,没有那个auto-import的提示了

 

 -Wl,<options>            Pass comma-separated <options> on to the linker (传递逗号分隔的选项给链接器)

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linker command struct c
相关文章推荐