Z
Z
Zadavatel_Voprosov2018-07-15 18:29:01
C++ / C#
Zadavatel_Voprosov, 2018-07-15 18:29:01

How to make Nuklear and CLion friends with MinGw-W64 (Windows and C without ++)?

Hello! I thought that I needed some kind of small GUI without any dependencies and preferably cross-platform (+ so that it was in SI). For this I chose Nuklear .
I extract all the files in the src folder from the archive and put them in Папочка_Проекта/libs/nuklear.

I add the path to the library to CMakeLists.txt:

cmake_minimum_required(VERSION 3.10)
project(MozetGui C)

set(CMAKE_C_STANDARD 11)

add_executable(MozetGui main.c)

target_include_directories( MozetGui PUBLIC ${CMAKE_SOURCE_DIR}/libs/nuklear )

To check I compile:
#define NK_IMPLEMENTATION
#include <nuklear.h>

And I get:
"C:\Program Files\JetBrains\CLion 2018.1.5\bin\cmake\bin\cmake.exe" --build C:\Users\Timoshka-WIN10\Documents\CLionProjects\MozetGui\cmake-build-debug --target MozetGui -- -j 1
Scanning dependencies of target MozetGui
[ 50%] Building C object CMakeFiles/MozetGui.dir/main.c.obj
[100%] Linking C executable MozetGui.exe
C:/PROGRA~2/MINGW-~1/I686-8~1.0-W/mingw32/bin/../lib/gcc/i686-w64-mingw32/8.1.0/../../../../i686-w64-mingw32/lib/../lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text.startup+0x39): undefined reference to `[email protected]'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[3]: *** [CMakeFiles\MozetGui.dir\build.make:97: MozetGui.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:67: CMakeFiles/MozetGui.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:79: CMakeFiles/MozetGui.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:117: MozetGui] Error 2

And I didn’t understand anything here, it seems that everything is ok with the code, but the compiler broke my brains.
How to glue the brains of the compiler? :))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2018-07-15
@GavriKos

The compiler is ok. The linker broke the brains. Is it the source code, or the headers + the library? If the latter, then tell the linker where to find the library.

Z
Zadavatel_Voprosov, 2018-07-18
@Zadavatel_Voprosov

In any case, it will not work without a function int main() { /* Кодик */ }and will crash into a linking error.
Don't use crap like toster.ru .
Better help on ru.stackoverflow.com , and better ask questions at once in two places .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question