Code::Blocks Forums

User forums => Help => Topic started by: bijanbina on January 10, 2011, 04:54:30 pm

Title: Build option [Solved]
Post by: bijanbina on January 10, 2011, 04:54:30 pm
Hi i write a program that write a message in gnome as notification bar

i can compile it in Terminal with command

Code
gcc `pkg-config --cflags gtk+-2.0` `pkg-config --cflags glib-2.0` -lnotify main.c -o hi

but in code block i got error because  i don't know how set this option in code::block can you help me

i set this options in build option window at other option tab but it doesn't work!
and in below u can see my code

Code
#include <libnotify/notify.h>
#include <stdio.h>
#include <unistd.h>

int main(int argc, char * argv[] )
{
    NotifyNotification *n;

    notify_init("Basics");

    n = notify_notification_new ("Summary",
                                 "This is the message that we want to display",
                                  NULL, NULL);
    notify_notification_set_timeout (n, 5000); // 5 seconds

    if (!notify_notification_show (n, NULL))
    {
    fprintf(stderr, "failed to send notification\n");
    return 1;
    }

    g_object_unref(G_OBJECT(n));

    return 0;
}


-------------------------------------------------------------------------------------------
Solution:Go to Project -> Build options  In linker setting add notify
Title: Re: Build option
Post by: oBFusCATed on January 10, 2011, 06:01:57 pm
Read this: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

And the C::B's manual
Title: Re: Build option
Post by: bijanbina on January 11, 2011, 04:11:58 am
Read this: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

And the C::B's manual
thanks but in your first link it said that how we can see the compiler output and i look for my problem in C::B's manual but i couldn't find it
Title: Re: Build option
Post by: Jenna on January 11, 2011, 08:11:02 am
C::B always uses two passes.
building and linking.

For building the "pkg-config"-commands have to go into "Project -> Build options... -> [Project or target] -> Compiler settings -> Other options",
for linking into "Project -> Build options... -> [Project or target] -> Linker settings -> Other linker settings:",
The library goes into "Project -> Build options... -> [Project or target] -> Linker settings -> Link libaries" (in your case it should be enough to just add notify).

For the pkg-config commands, don't forget the backticks.

Full commandline-logging helps you to see what commands are used to invoke the compiler, so you can easily fix possible errors.
Title: Re: Build option
Post by: bijanbina on January 11, 2011, 12:32:48 pm
thanks it works!