User forums > General (but related to Code::Blocks)

GTK 3 in Ubuntu and Code::Blocks

<< < (2/2)

ordak:
In order to build GTK3 as a library , I created a "Static library" project. Note that compilation usually takes about 20sec to 1min.

main.c : // for GTK3 project

--- Code: ---void sample_function (void);
void sample_function (void)
{
    return;
}

--- End code ---

Here is the last part of Build log :


--- Code: ---ar r bin/Release/libGTK3_SL.a obj/Release/main.o
ar: creating bin/Release/libGTK3_SL.a
Output file is bin/Release/libGTK3_SL.a with size 1.02 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

--- End code ---


* Why static library file is about 1KB , is not that too small ?
Temp project Main.c :


--- Code: ---#include "gtk/gtk.h"
//#include <gtk/gtk.h>
[...]

--- End code ---

Error for Temp project calling GTK3 :

--- Code: ---
-------------- Clean: Release in Temp (compiler: LLVM Clang Compiler 9 GTK)---------------

Cleaned "Temp - Release"

-------------- Build: Release in Temp (compiler: LLVM Clang Compiler 9 GTK)---------------

clang -m64 -pedantic -Weverything -Wall -std=c11  -c /home/mehdi/Documents/Code_Blocks_Projects/Temp/Main.c -o obj/Release/Main.o
/home/mehdi/Documents/Code_Blocks_Projects/Temp/Main.c:2:10: fatal error: 'gtk/gtk.h' file not found
#include "gtk/gtk.h"
         ^~~~~~~~~~~
1 error generated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
 

--- End code ---

In "Linker setting" I have :


--- Code: ---/home/mehdi/Documents/Code_Blocks_Projects/GTK3_SL/bin/Release/libGTK3_SL.a

--- End code ---


* Why when I link to this library and I want to call gtk.h I receive an error ?

stahta01:

--- Quote ---
--- Code: ---fatal error: 'gtk/gtk.h' file not found
--- End code ---

--- End quote ---

You need to know the difference between linker and compiler errors!

What you posted was a Compiler Error; look in the Compiler setting.

Tim S.

ordak:

--- Quote from: stahta01 on November 01, 2019, 04:42:03 pm ---
--- Quote ---
--- Code: ---fatal error: 'gtk/gtk.h' file not found
--- End code ---

--- End quote ---

You need to know the difference between linker and compiler errors!

What you posted was a Compiler Error; look in the Compiler setting.

Tim S.

--- End quote ---

OK , I added `pkg-config --cflags gtk+-3.0` to "Compiler setting / Other compiler options" and now Temp compiles.

ordak:
Now I am able to compile and show a window but why I get this error in "Build messages" :


--- Code: ---error: Callback to invoke when an error occurs.
--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version