一开始按照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 报错的一个解决方案的更多相关文章

  1. gcc编译代码报错及编译方式

    一.error: 'for' loop initial declarations are only allowed in C99 mode 前段时间写了一个小C程序,放在linux下用gcc编译出错, ...

  2. [Linux][C][gcc] Linux GCC 编译链接 报错ex: ./libxxx.so: undefined reference to `shm_open'

    本人原创文章,文章是在此代码github/note的基础上进行补充,转载请注明出处:https://github.com/dramalife/note. 以librt丶用户自定义动态库libxxx 和 ...

  3. 源码编译apache报错的解决方法

    源码编译apache报错的解决方法   问题介绍 在源码编译安装httpd时,./configure执行无错误,到make时就报错,在网络上搜索了很多文章,很多方法如换apr-util的低版本并不能很 ...

  4. LINUX下基于NVIDIA HPC SDK 的 VASP6.3.x编译安装报错整理

    关于gcc 用旧版本安装NVIDIA HPC SDK再编译会报错: "/opt/rh/devtoolset-8/root/usr/include/c++/8/bits/move.h" ...

  5. 编译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 ...

  6. idea中编译项目报错 java: javacTask: 源版本 1.8 需要目标版本 1.8

    问题如上面所叙: > idea中编译项目报错 java: javacTask: 源版本 1.8 需要目标版本 1.8 解决方案: > Setting->Compiler->Ja ...

  7. 编译 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 ...

  8. webpack编译sass报错找不到module /css-loader/index.js... || 安装node-sass报错

    今天无论在家还是在公司,安装node-sass总是失败,或安装成功了,使用webpack编译sass报错,说找不到module,按照提示的错误我找了node_modules下的css-loader,发 ...

  9. 后台程序编译过程报错PCC-F-02104, Unable to connect to Oracle

    偶然重新编译了一下后台程序,发现编译过程报错无法连接数据库.但通过sqlplus登录数据库是正常的.后台程序改动中也做了详细的分析,没有改动相关数据库的参数和配置. 最后通过浏览器查看了很多相关问题的 ...

随机推荐

  1. oracle自定义排序和NULL值排序

    1.自定义顺序 当我们希望将某个查询结果指定的显示顺序展示的时候 order by case when column1=1 then 0 case when column1=1 then 1 else ...

  2. RES协议和断网访问URL出现的错误页面

    # 11 Id: 26a4.1470 Suspend: 1 Teb: 7ff9f000 Unfrozen # Memory ChildEBP RetAddr Args to Child 00 01ca ...

  3. Java锁优化

    Java锁优化 应用程序在并发环境下会产生很多问题,通常情况下,我们可以通过加锁来解决多线程对临界资源的访问问题.但是加锁往往会成为系统的瓶颈,因为加锁和释放锁会涉及到与操作系统的交互,会有很大的性能 ...

  4. <JavaScript> 匿名函数和闭包的区别

    匿名函数:没有名字的函数:并没有牵扯到应用其他函数的变量问题.仅仅是没有名字. 定义方式: 1,var A = function(){ }; 2, (function (x,y){ })(2,3); ...

  5. 5.性能测试工具比较:Jmeter和LR

    性能测试工具较多,无法一一进行介绍,感兴趣者可自行搜索资料学习.需要说明的是工具使用方法和原理都大同小异,掌握一个,其他皆可快速上手. 下面就以服务端的性能测试工具为例,对市场上最常用,知名度较高,也 ...

  6. PLSQL Developer配置OCI连接远程数据库

    转: PLSQL Developer配置OCI连接远程数据库 当前环境: 本机系统:Win7 32位 PLSQL版本:9.06 数据库版本:10.2 32位 下面开始具体操作. 1.在Oracle官网 ...

  7. 在Windows操作系统中安装MongoDB

    如何在Windows操作系统中安装MongoDB: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/ 启动Mon ...

  8. 重写equals方法需要知道的事

    重写equals方法 相信在每个人都有过重写过java的equals的方法的经历.这篇博文就从以下几个方面说明重写equals方法的原由,与君共进步. 一 为什么要重写equals方法 首先我们了解e ...

  9. IDEA配置SpringBoot应用的profile启动参数

    参考博客:https://blog.csdn.net/li396864285/article/details/83576829 如图为, 配置多台eureka的启动参数, 分别为: --spring. ...

  10. ABC技术落地_成功带动lot物联网行业、金融科技行业、智能人才教育。

    ABC技术:AI:Python神经网络和自然语言处理(NLP):C ++ 机器学习和神经网络:Java自然语言处理.搜索算法.神经网络:Lisp归纳逻辑项目和机器学习.Big Date:R.Pytho ...