cygwin gcc 编译windowsAPI 报错的一个解决方案
一开始按照linux的习惯去编译一个使用了windowsAPI的程序
结果提示:
$ i686-pc-cygwin-g++ screen_catch.c
screen_catch.c: In function ‘int main()’:
screen_catch.c:158:39: warning: ISO C++ forbids converting a string constant to ‘LPSTR {aka char*}’ [-Wwrite-strings]
SaveBitmapToFile(hBmp,"c:\\11.bmp");
^
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x38): undefined reference to `_imp__CreateDCA@16'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x53): undefined reference to `_imp__GetDeviceCaps@8'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x6d): undefined reference to `_imp__GetDeviceCaps@8'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x83): undefined reference to `_imp__DeleteDC@4'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x101): undefined reference to `_imp__GetObjectA@12'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x215): undefined reference to `_imp__GetStockObject@4'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x251): undefined reference to `_imp__SelectPalette@12'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x264): undefined reference to `_imp__RealizePalette@4'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x2aa): undefined reference to `_imp__GetDIBits@28'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x2cf): undefined reference to `_imp__SelectPalette@12'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x2df): undefined reference to `_imp__RealizePalette@4'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x48e): undefined reference to `_imp__CreateCompatibleDC@4'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x4c7): undefined reference to `_imp__CreateDIBSection@24'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x4e1): undefined reference to `_imp__SelectObject@8'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x52e): undefined reference to `_imp__BitBlt@36'
/tmp/cc2yXn3P.o:screen_catch.c:(.text+0x556): undefined reference to `_imp__DeleteDC@4'
collect2: error: ld returned 1 exit status
经过网上查找,发现是编译时没有链接到对应的库导致的。找到对应的库
g++ *.cpp -l Gdi32
编译成功。
cygwin gcc 编译windowsAPI 报错的一个解决方案的更多相关文章
- gcc编译代码报错及编译方式
一.error: 'for' loop initial declarations are only allowed in C99 mode 前段时间写了一个小C程序,放在linux下用gcc编译出错, ...
- [Linux][C][gcc] Linux GCC 编译链接 报错ex: ./libxxx.so: undefined reference to `shm_open'
本人原创文章,文章是在此代码github/note的基础上进行补充,转载请注明出处:https://github.com/dramalife/note. 以librt丶用户自定义动态库libxxx 和 ...
- 源码编译apache报错的解决方法
源码编译apache报错的解决方法 问题介绍 在源码编译安装httpd时,./configure执行无错误,到make时就报错,在网络上搜索了很多文章,很多方法如换apr-util的低版本并不能很 ...
- LINUX下基于NVIDIA HPC SDK 的 VASP6.3.x编译安装报错整理
关于gcc 用旧版本安装NVIDIA HPC SDK再编译会报错: "/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/move.h" ...
- 编译PHP 报错:node.c: In function dom_canonicalization
编译PHP 报错:node.c: In function dom_canonicalization /opt/php-5.2.17/ext/dom/node.c:1953: error: deref ...
- idea中编译项目报错 java: javacTask: 源版本 1.8 需要目标版本 1.8
问题如上面所叙: > idea中编译项目报错 java: javacTask: 源版本 1.8 需要目标版本 1.8 解决方案: > Setting->Compiler->Ja ...
- 编译 redis 报错 error: jemalloc/jemalloc.h: No such file or directory
gcc编译redis时报错: zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory zmalloc.h:55:2 ...
- webpack编译sass报错找不到module /css-loader/index.js... || 安装node-sass报错
今天无论在家还是在公司,安装node-sass总是失败,或安装成功了,使用webpack编译sass报错,说找不到module,按照提示的错误我找了node_modules下的css-loader,发 ...
- 后台程序编译过程报错PCC-F-02104, Unable to connect to Oracle
偶然重新编译了一下后台程序,发现编译过程报错无法连接数据库.但通过sqlplus登录数据库是正常的.后台程序改动中也做了详细的分析,没有改动相关数据库的参数和配置. 最后通过浏览器查看了很多相关问题的 ...
随机推荐
- Python实现进度条的效果
from itertools import cycle from time import sleep for frame in cycle(r'-\|/-\|/'): print('\r', fram ...
- 一个数据库操作类,适用于Oracle,ACCESS,SQLSERVER
最近做了一个数据诊断的项目,里面自己写了一个数据库的操作类,包含:连接数据库.读数据表.执行SQL操作,释放数据库等组成,希望对大家有用,由于水平有限,若有错误或者代码不足地方欢迎指正,谢谢. ADO ...
- kvm安装及简单使用
1 cat /etc/redhat-release CentOS release 6.4 (Final)2 egrep ‘vmx|svm’ /proc/cpuinfo3 yum -y ins ...
- 《你不知道的JavaScript(上)》笔记——作用域闭包
当函数可以记住并访问所在的词法作用域时, 就产生了闭包, 即使函数是在当前词法作用域之外执行. function wait(message) { setTimeout( function timer( ...
- 免费下载 SetupVPN CRX 3.7.0 for Chrome OR QQ浏览器
免费下载 SetupVPN CRX 3.7.0 for Chrome OR QQ浏览器 Lifetime Free VPN(微劈嗯) 下载setupvpn 3.7.0的crx文件, 打开chrome的 ...
- CentOS源码安装 Tomcat/8.0.24
依个人的习惯,喜欢将源码安装在/usr/local这个目录下面: 第一步:下载源码 wget http://archive.apache.org/dist/tomcat/tomcat-8/v8.0.2 ...
- 20 Flutter仿京东商城项目 商品详情 底部弹出筛选属性 以及筛选属性页面布局
ProductContentFirst.dart import 'package:flutter/material.dart'; import '../../widget/JdButton.dart' ...
- CentOS7 升级 python3 过程及注意
• 从官网下载python3的压缩包,解压(以3.5.1版本为例)• 创建安装目录(自定义)sudo mkdir /usr/local/python3• cd 进入解压目录sudo ./configu ...
- OpenStack Manila发展动态系列--Austin峰会
1 Manila Mitaka版本概述 在Austin峰会上介绍到,Manila Mitaka发布版本Driver个数达到了18个, M版本新加入14家公司(中国公司继华为之后又有99cloud等公司 ...
- 使用jquery 动态创建form 并提交
$(document).ready(function(){ $("a.delete").click(function(event){ action = this ...