简体   繁体   English

如何将我正在交叉编译的程序的ubuntu上的GLEW交叉编译到Windows?

[英]How can I cross-compile GLEW on ubuntu to windows for a program I am cross-compiling?

I am working on a little project with OpenGL, GLU, freeGLUT, GLEW, and SOIL (an image loader for opengl textures). 我正在使用OpenGL,GLU,freeGLUT,GLEW和SOIL(用于opengl纹理的图像加载器)进行一个小项目。 I would like to cross-compile my project to windows, as it is eventually going to be a game I plan to sell, and more people use Windows than Linux. 我想将我的项目交叉编译到Windows,因为它最终将成为我计划出售的游戏,并且使用Windows的人要多于Linux。 Unfortunately, the cross-compiler I am using, MinGW, does not support the pre-built libraries of GLEW on the GLEW website. 不幸的是,我使用的交叉编译器MinGW不支持GLEW网站上的GLEW预先构建的库。

I have the GLEW source code bundle downloaded, how can I compile that into the libglew32.a (and two other files I forget the name of, one is a static version I think) files I need? 我已经下载了GLEW源代码包,如何将其编译到libglew32.a(以及我忘记名字的其他两个文件,我认为是静态版本)文件中? There is a makefile already included, should I use that? 已经有一个makefile,我应该使用吗? (I'm just not sure if that will make a library usable for MinGW) (我不确定这是否会使MinGW可以使用库)

TL;DR How do I compile GLEW for MinGW on ubuntu? TL; DR如何在ubuntu上为MinGW编译GLEW?

When creating software that's intended to run on several platforms and you're planning to cross compile, it's always a good idea to include the sources of 3rd party libraries (or the libraries themself if you don't have the source code) into your projects source and build tree. 当创建打算在多个平台上运行的软件并且打算进行交叉编译时,将第三方库的源代码(如果没有源代码,则包含库本身)始终包含在项目中总是一个好主意。源并构建树。

Ideally everything can be built out-of-source-tree, but sometimes (often) that's not the case, so you've to do several builds manually, copying the resulting binaries at some place your main project's build system can access them. 理想情况下,所有内容都可以在源代码树之外构建,但是有时(通常)并非如此,因此您必须手动执行多个构建,将生成的二进制文件复制到主项目的构建系统可以访问它们的某个位置。

For cross compiling it usually boils down to exactly specify which toolchain binaries to use. 对于交叉编译,它通常归结为准确指定要使用的工具链二进制文件。 For example on Linux the MinGW cross compilers usually are named something like i686-w64-mingw32-… (or similar). 例如,在Linux上,MinGW交叉编译器通常被命名为i686-w64-mingw32-… (或类似名称)。 When configuring the 3rd party libraries build you've to specify which ones to use. 在配置第三方库构建时,您必须指定要使用的库。 Depending on the build system this either happens through the CC , CXX , LD and some other environment variables, or through the BUILD , HOST and TARGET variables (see here https://stackoverflow.com/a/5139451/524368 ). 根据构建系统的不同,这可能通过CCCXXLD和其他一些环境变量发生,或者通过BUILDHOSTTARGET变量发生(请参见此处https://stackoverflow.com/a/5139451/524368 )。

The best situation is, if you can integrate everything that's 3rd party into your projects build system, because that relieves you from manually managing that. 最好的情况是,如果您可以将第三者的所有内容都集成到项目构建系统中,因为这样可以避免手动管理它。 Personally I've come to like the CMake build system a lot, because it supports out-of-tree builds and if you've got libraries that use CMake themself you can simply copy their source trees into a subdirectory of your project and include their CMake configuration. 我个人非常喜欢CMake构建系统,因为它支持树外构建,如果您自己使用了CMake库,则可以简单地将其源树复制到项目的子目录中并包括它们CMake配置。

Note that's it's often a valid option to replace a projects build system if the build itself is not too complicated (replacing the build system of something like the Linux kernel or ffmpeg is madness, replacing the build system of something like GLFW may be a viable option). 请注意,如果构建本身不太复杂(替换诸如Linux内核或ffmpeg之类的构建系统是疯狂的事情),那么替换项目构建系统通常是一个有效的选择,而替换诸如GLFW之类的构建系统可能是一个可行的选择。 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从Linux交叉编译到Windows时,应如何处理字符编码? - How should I handle character encoding when cross-compiling from Linux to Windows? 与Clang交叉编译时如何实现原生级优化? - How can I achieve native-level optimizations when cross-compiling with Clang? 使用 cmake 在 Linux for Windows 上交叉编译程序 - Cross-Compiling a program on Linux for Windows using cmake 如何为Eclipse中的交叉编译项目有条件地包括两个版本相同的名称不同的库? - How can I conditionally include two differently named libraries of the same version for a cross-compile project in Eclipse? 如何将QT应用程序从ubuntu交叉编译到Windows? - How do I cross compile QT application from ubuntu to windows? 将Ubuntu交叉编译到Centos GLIBCXX时出错 - Errors on cross-compiling Ubuntu to Centos GLIBCXX 在ubuntu上交叉编译针对ARM的openCV - Cross-Compiling openCV for ARM on ubuntu 交叉编译程序找不到SDL2标头 - Cross-compile program can't find SDL2 headers 交叉编译和链接i686-elf的libstdc ++(在Ubuntu 16.04上使用g ++) - Cross-compile and link libstdc++ for i686-elf (using g++ on Ubuntu 16.04) 在Linux上交叉编译Windows应用程序时如何链接到Winsock? - How to link to Winsock when cross-compiling a Windows app on Linux?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM