简体   繁体   English

在premake4中将C ++与C混合?

[英]Mix C++ with C in premake4?

I am trying to use premake4 to compile a C++ OpenGL project. 我正在尝试使用premake4来编译C++ OpenGL项目。 And I choose glad to help me make it cross-platform. 而且我选择很高兴帮助我使其跨平台。

Hence, I write the following script premake4.lua 因此,我编写了以下脚本premake4.lua

solution "skinned-animation"
    configurations { "Debug", "Release" }

project "skinned-animation"
    kind "ConsoleApp"
    language "C++"
    linkoptions { "-L/usr/local/lib", "-lboost_system", "-lboost_filesystem", "-lglfw" }

    includedirs { "../prerequisite", "/usr/local/include" }
    files { "../skinned-animation/**.h", "../skinned-animation/**.cpp", "../skinned-animation/**.c" }

    buildoptions { "-std=c++14" }

However, the problem is that premake will exert the flag -std=c++14 to all both C (only glad.c actually) and C++ files. 但是,问题在于premake将对所有C (实际上仅是glad.c )和C++文件都施加标志-std=c++14 And that leads to an error. 这会导致错误。

How can we distinguish C and C++ and give them different flags because premake4 doesn't have filter ? 由于premake4没有filter我们如何区分CC++并赋予它们不同的标志?

In the end, I choose to compile glad.c to static library first with the following instruction and then link it to my project: 最后,我选择首先使用以下指令将glad.c编译为静态库,然后将其链接到我的项目:

clang -c glad.c
ar rcs libglad.a glad.o

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM