Compiling glfw-3.2.1 manually

windows 7 - 64 bit
GNU make 3.81
glfw-3.2.1
cmake 3.6.2

hey,

I have a vulkan / glfw project. I’d like to compile my project via makefile. no IDE, which means, no visual studio, codeblocks and so on. the precompiled libraries are for visual studio only. there is one for mingw, that doesn’t work during linking stage.

makefile:

VERSION = 1.00

CFLAGS = -Wall -Wpedantic -Wextra -std=gnu++11 

# Engine

DE_H001 = de_core.h
DE_H002 = de_error.h
DE_H003 = de_glb.h

DE_S001 = de_core.cpp

# Framework

FW_S001 = fw_main.cpp

# Combined

SRC_ALL = $(DE_S001) $(FW_S001)
H_ALL = $(DE_H001) $(DE_H002) $(DE_H003)

VulkanFramework: $(SRC_ALL) $(H_ALL)
    mingw32-c++ $(CFLAGS) $(SRC_ALL) $(H_ALL) -o VulkanFramework -L lib/ -lglfw3 -lglfw3dll -lpthread

there is a lib folder, where glfw3.dll, libglfw3.a, libglfw3dll.a are located, taken from the “glfw-3.2.1.bin.WIN64” download folder.

Since I recieve a “undefined reference” error on every glfw function, I guess these libraries aren’t suiteable for my OS. So I downloaded the source package and tried to compile it via cmake. that didn’t work… 'cause cl.exe is unknown to my OS. (cl.exe is visual studio again)

so I guess I have to compile it totally manually, since I didn’t find any pre compiled libraries for MinGW. I read this section: compile manual

but it doesn’t say anything about the right flags for vulkan support. so what can I do?

Note: you might be having the same problem I helped solve in this thread - one issue was that the compiler needed to be run as two commands, first compile and then link.

You shouldn’t need to set any flags to get Vulkan support (it’s build in).

See the GLFW Vulkan guide for what you do once you have a working set of GLFW libraries. Note that you need the LunarG SDK, and I don’t know how easy that is to use with MinGW.

Since Visual Studio Community edition is free to use for home and small studio use, and you can run compiles from the command line, you could try that if you get into problems.

-lglfw3 -lglfw3dll

These are mutually exclusive. Pick one of them. The former is the GLFW static library and the latter is the import library for the GLFW DLL. If you pick glfw3dll then you need to define GLFW_DLL.

there is a lib folder, where glfw3.dll, libglfw3.a, libglfw3dll.a are located, taken from the “glfw-3.2.1.bin.WIN64” download folder.

It looks like you are using regular MinGW (mingw32-c++), which only produces 32-bit code. You cannot mix 32- and 64-bit code. Your linker is ignoring the GLFW binaries as they are 64-bit.

Thanks - I didn’t notice the mix of dll and static libs, nor the 64bit issue.