# Compiling glfw-3.2.1 manually

**URL:** <https://discourse.glfw.org/t/compiling-glfw-3-2-1-manually/758>\
**Category:** support\
**Created:** [September 12, 2016, 9:00am UTC](https://discourse.glfw.org/t/compiling-glfw-3-2-1-manually/758 "2016-09-12T09:00:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PadMad](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@PadMad](https://discourse.glfw.org/u/PadMad)\
**Post date:** [September 12, 2016, 9:00am UTC](https://discourse.glfw.org/t/compiling-glfw-3-2-1-manually/758/1 "2016-09-12T09:00:44Z")

</div>

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](http://www.glfw.org/docs/3.0/compile.html#compile_manual)

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

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 12, 2016, 9:46am UTC](https://discourse.glfw.org/t/compiling-glfw-3-2-1-manually/758/2 "2016-09-12T09:46:04Z")

</div>

Note: you might be having [the same problem I helped solve in this thread](http://discourse.glfw.org/t/the-process-of-creating-a-simple-glfw-test-program-question/179/11?u=dougbinks) - 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](http://www.glfw.org/docs/latest/vulkan_guide.html) 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.

---

<div class="post-metadata">

**Author:** ![elmindreda](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/elmindreda/32/26_2.png) [@elmindreda](https://discourse.glfw.org/u/elmindreda)\
**Post date:** [September 14, 2016, 7:54pm UTC](https://discourse.glfw.org/t/compiling-glfw-3-2-1-manually/758/3 "2016-09-14T19:54:52Z")

</div>

> `-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`](http://www.glfw.org/docs/3.2/build_guide.html#build_macros).

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

---

<div class="post-metadata">

**Author:** ![dougbinks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.glfw.org/dougbinks/32/39_2.png) [@dougbinks](https://discourse.glfw.org/u/dougbinks)\
**Post date:** [September 14, 2016, 9:41pm UTC](https://discourse.glfw.org/t/compiling-glfw-3-2-1-manually/758/4 "2016-09-14T21:41:49Z")

</div>

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