Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. [SOLVED CLOSED] See addendum GCC ` backtick` CLI - what does it actually do ?

[SOLVED CLOSED] See addendum GCC ` backtick` CLI - what does it actually do ?

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialannouncementvisual-studio
12 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Peter_in_2780

    Run your backticked phrase (without backticks), redirected to a file. Then you can see what it injects into your command line when it's used backticked. Something like

    pkg-config --cflags gtk+-3.0 > lookatmeclosely

    Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

    V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #3

    Thanks, but I know what is does - look at all the -I in the attached file. I think g++ also needs -l - libraries or library - for GTK. But I am not sure how to do it if I need more. Can I use similar method as pkg-config to get -l /-L ? Addendum Did some research and found this z@z-desktop:~$ pkg-config --libs gtk+-3.0 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 That is what is needed. However adding another backtick string `pkg-config --libs gtk+-3.0` did not produced expected libraries. Will do some experimentation with that - it should work. More edit If I add `pkg-config --libs gtk+-3.0` to linker options I get about 20 additional -l libraries in output. However I still get "undefined reference " error. Later...

    K 1 Reply Last reply
    0
    • V Vaclav_

      Thanks, but I know what is does - look at all the -I in the attached file. I think g++ also needs -l - libraries or library - for GTK. But I am not sure how to do it if I need more. Can I use similar method as pkg-config to get -l /-L ? Addendum Did some research and found this z@z-desktop:~$ pkg-config --libs gtk+-3.0 -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 That is what is needed. However adding another backtick string `pkg-config --libs gtk+-3.0` did not produced expected libraries. Will do some experimentation with that - it should work. More edit If I add `pkg-config --libs gtk+-3.0` to linker options I get about 20 additional -l libraries in output. However I still get "undefined reference " error. Later...

      K Offline
      K Offline
      k5054
      wrote on last edited by
      #4

      Make sure you are adding the --libs option to the link phase in your IDE. e.g. compiler flags : ... \`pkg-config --cflags gtk+-3.0\` ... linker flags : ... \`pkg-config --libs gtk+-3.0\` ... As an aside, you should be aware that the backtick idiom is a shell level construct, and is not anything specific to gcc. so you could do the following :

      $ ls -l \`find . -name *.cpp\`

      Which would produce a long listing of all cpp files in the current directory tree.

      Keep Calm and Carry On

      V 1 Reply Last reply
      0
      • K k5054

        Make sure you are adding the --libs option to the link phase in your IDE. e.g. compiler flags : ... \`pkg-config --cflags gtk+-3.0\` ... linker flags : ... \`pkg-config --libs gtk+-3.0\` ... As an aside, you should be aware that the backtick idiom is a shell level construct, and is not anything specific to gcc. so you could do the following :

        $ ls -l \`find . -name *.cpp\`

        Which would produce a long listing of all cpp files in the current directory tree.

        Keep Calm and Carry On

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #5

        OK, putting wrong option may be one of the issues. I did put BOTH --cflag and --libs in complier and linker options. I also tried this combined syntax `pkg-config --cflags --libs gtk+-3.0` The compiler and linker verbose outputs looks OK ( too big to repost here ) , BUT the unresolved error is apparently different issue. I am enclosing what I posted in Eclipse forum here: This error has been posted years ago and there was NO SOLUTION, See this old post [b]However, this only solved the issue of adding all the header files manually. Now I encounter errors like "Function 'G_CALLBACK' could not be resolved". I tried to compile my source-code (the first example of the GTK3 tutorial) in a terminal using the simple "gcc `pkg-config --cflags gtk+-3.0` -o example-0 First_GTK_test.cpp `pkg-config --libs gtk+-3.0`" command and it works. So the issue must be an Eclipse setting issue.[/b] Every GTK tutorial is same - download / install GTK and run sample code in your editor... It is up to the user to figure out how to option complier / linker to "include sources and link libraries" Adding `pkg-config --cflags --libs gtk+-3.0` should work, I get expected verbose output , but it does not. Even after that is done the compilation will fail because #include is unresolved. Here is an output of whereis z@z-desktop:~$ whereis gtk.h gtk: z@z-desktop:~$ Any help woudl be appreciated End of Eclipse post. I am really at lost where the reference came from and unsure how to find gtk.h manually - where ? Appreciate all the help with such trivial issue. Cheers

        V 1 Reply Last reply
        0
        • V Vaclav_

          OK, putting wrong option may be one of the issues. I did put BOTH --cflag and --libs in complier and linker options. I also tried this combined syntax `pkg-config --cflags --libs gtk+-3.0` The compiler and linker verbose outputs looks OK ( too big to repost here ) , BUT the unresolved error is apparently different issue. I am enclosing what I posted in Eclipse forum here: This error has been posted years ago and there was NO SOLUTION, See this old post [b]However, this only solved the issue of adding all the header files manually. Now I encounter errors like "Function 'G_CALLBACK' could not be resolved". I tried to compile my source-code (the first example of the GTK3 tutorial) in a terminal using the simple "gcc `pkg-config --cflags gtk+-3.0` -o example-0 First_GTK_test.cpp `pkg-config --libs gtk+-3.0`" command and it works. So the issue must be an Eclipse setting issue.[/b] Every GTK tutorial is same - download / install GTK and run sample code in your editor... It is up to the user to figure out how to option complier / linker to "include sources and link libraries" Adding `pkg-config --cflags --libs gtk+-3.0` should work, I get expected verbose output , but it does not. Even after that is done the compilation will fail because #include is unresolved. Here is an output of whereis z@z-desktop:~$ whereis gtk.h gtk: z@z-desktop:~$ Any help woudl be appreciated End of Eclipse post. I am really at lost where the reference came from and unsure how to find gtk.h manually - where ? Appreciate all the help with such trivial issue. Cheers

          V Offline
          V Offline
          Vaclav_
          wrote on last edited by
          #6

          OK, this makes no sense Eclipse IDE has under includes /usr/include BUT I had to add this full path manually to get rid of " file doe snot exist " AKA undefined reference #include /usr/include/gtk-3.0/gtk/gtk.h ( < > won't show !!!! ) Now my first usage of GTK gives the "undefined reference " error - same as the very old post on Eclipse. In my view - the "top reference" is OK, but anything "bellow" is still unreferenced. This is a mess...

          K 1 Reply Last reply
          0
          • V Vaclav_

            OK, this makes no sense Eclipse IDE has under includes /usr/include BUT I had to add this full path manually to get rid of " file doe snot exist " AKA undefined reference #include /usr/include/gtk-3.0/gtk/gtk.h ( < > won't show !!!! ) Now my first usage of GTK gives the "undefined reference " error - same as the very old post on Eclipse. In my view - the "top reference" is OK, but anything "bellow" is still unreferenced. This is a mess...

            K Offline
            K Offline
            k5054
            wrote on last edited by
            #7

            I'm fairly sure that the "undefined reference" is a link phase error, not a compile phase problem, so I don't think changing the headers or header search path will not help you

            Vaclav_ wrote:

            Eclipse IDE has under includes /usr/include

            I don't use eclipse, but it looks to me like that's a path, so I think you would add /usr/include/gtk-3.0 assuming you're adding #include to your source file If you're getting the object files compiled successfully, but not getting the linking done then try, from a command line

            gcc file1.o file2.o ... \`pkg-config --libs gtk+-3.0\` -o myapp

            if you're compiling C++ code, use g++ to link, not gcc, as that will link in stdlib++.o, and do anything else that C++ needs that plain C doesn't I don't see where you've said exactly what the undefined reference you're getting is. Its possible that its not a gtk+ function, but maybe a math (eg. abs, ceil cos) or function from another library.

            Keep Calm and Carry On

            V L 2 Replies Last reply
            0
            • K k5054

              I'm fairly sure that the "undefined reference" is a link phase error, not a compile phase problem, so I don't think changing the headers or header search path will not help you

              Vaclav_ wrote:

              Eclipse IDE has under includes /usr/include

              I don't use eclipse, but it looks to me like that's a path, so I think you would add /usr/include/gtk-3.0 assuming you're adding #include to your source file If you're getting the object files compiled successfully, but not getting the linking done then try, from a command line

              gcc file1.o file2.o ... \`pkg-config --libs gtk+-3.0\` -o myapp

              if you're compiling C++ code, use g++ to link, not gcc, as that will link in stdlib++.o, and do anything else that C++ needs that plain C doesn't I don't see where you've said exactly what the undefined reference you're getting is. Its possible that its not a gtk+ function, but maybe a math (eg. abs, ceil cos) or function from another library.

              Keep Calm and Carry On

              V Offline
              V Offline
              Vaclav_
              wrote on last edited by
              #8

              I am including , again, full complier / linker output. This is for purpose of discussion , I hope I can delete it later. Here is a full verbose output of complier and linker, note slew of "includes". In theory #include /gtk/gtk.h should work. If the error is flagged in IDE as " file not accessible" does it really matters if it is complier or linker error? ( The Eclipse refers to complier as "Linux GCC" then as "GCC C++ Complier" however the actuall options string starts with "g++". Semantics???) 10:50:35 **** Build of configuration Debug for project GTK_WIKI **** make all Building file: ../src/GTK_WIKI.cpp Invoking: GCC C++ Compiler g++ -I/usr/include/gtk-3.0/gtk -O0 -g3 -Wall -c -fmessage-length=0 `pkg-config --cflags --libs gtk+-3.0` -v -MMD -MP -MF"src/GTK_WIKI.d" -MT"src/GTK_WIKI.o" -o "src/GTK_WIKI.o" "../src/GTK_WIKI.cpp" Using built-in specs. COLLECT_GCC=g++ Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.4.0-6ubuntu1~16.04.12' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) COLLECT_GCC_OPTIONS='-I' '/usr/include/gtk-3.0/gtk' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-pthread' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/at-spi2-atk/2.0' '-I' '/usr/include/at-spi-2.0' '-I' '/usr/include/dbus-1.0' '-I' '/usr/lib/x86_64-linux-gnu/dbus-1.0/include' '-I' '/usr/include/gtk-3.0' '-I' '/usr/include/gio-uni

              1 Reply Last reply
              0
              • K k5054

                I'm fairly sure that the "undefined reference" is a link phase error, not a compile phase problem, so I don't think changing the headers or header search path will not help you

                Vaclav_ wrote:

                Eclipse IDE has under includes /usr/include

                I don't use eclipse, but it looks to me like that's a path, so I think you would add /usr/include/gtk-3.0 assuming you're adding #include to your source file If you're getting the object files compiled successfully, but not getting the linking done then try, from a command line

                gcc file1.o file2.o ... \`pkg-config --libs gtk+-3.0\` -o myapp

                if you're compiling C++ code, use g++ to link, not gcc, as that will link in stdlib++.o, and do anything else that C++ needs that plain C doesn't I don't see where you've said exactly what the undefined reference you're getting is. Its possible that its not a gtk+ function, but maybe a math (eg. abs, ceil cos) or function from another library.

                Keep Calm and Carry On

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #9

                The undefined ref is gtk_window_new defined in GtkWindow: GTK+ 3 Reference Manual[^]. No idea what OP is trying to do, as usual he has not explained.

                K 1 Reply Last reply
                0
                • L Lost User

                  The undefined ref is gtk_window_new defined in GtkWindow: GTK+ 3 Reference Manual[^]. No idea what OP is trying to do, as usual he has not explained.

                  K Offline
                  K Offline
                  k5054
                  wrote on last edited by
                  #10

                  How did you pick that up? I copied the entire output posted at the top of this thread, and a) a search for "undefined" turned up nothing, and b) as currently shown, the compile completes successfully!! Doing a quick perusal of the rest of the thread, I didn't notice any further mention of exactly what was undefined. At this point, I have no idea what the problem is, since it looks to me like the compile/link is correct - -lgtk-3 is in the link options. Maybe Eclipse is doing something odd.

                  Keep Calm and Carry On

                  V L 2 Replies Last reply
                  0
                  • K k5054

                    How did you pick that up? I copied the entire output posted at the top of this thread, and a) a search for "undefined" turned up nothing, and b) as currently shown, the compile completes successfully!! Doing a quick perusal of the rest of the thread, I didn't notice any further mention of exactly what was undefined. At this point, I have no idea what the problem is, since it looks to me like the compile/link is correct - -lgtk-3 is in the link options. Maybe Eclipse is doing something odd.

                    Keep Calm and Carry On

                    V Offline
                    V Offline
                    Vaclav_
                    wrote on last edited by
                    #11

                    Here is the part of actual code #include /usr/include/gtk-3.0/gtk/gtk.h // edited so it show int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *label; cout << "WINDOW sample code" << endl; // prints /* Create the main, top level window */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); And here is the tail of the compile / link process ./src/GTK_WIKI.o: In function `main': /media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2020_228/work_228/GTK_WIKI/Debug/../src/GTK_WIKI.cpp:49: undefined reference to `gtk_window_new' collect2: error: ld returned 1 exit status makefile:45: recipe for target 'GTK_WIKI' failed make: *** [GTK_WIKI] Error 1 "make all" terminated with exit code 2. Build might be incomplete. 12:30:58 Build Failed. 3 errors, 2 warnings. (took 2s.647ms) Any actual , constructive help to solve the problem is appreciated. Cheers

                    1 Reply Last reply
                    0
                    • K k5054

                      How did you pick that up? I copied the entire output posted at the top of this thread, and a) a search for "undefined" turned up nothing, and b) as currently shown, the compile completes successfully!! Doing a quick perusal of the rest of the thread, I didn't notice any further mention of exactly what was undefined. At this point, I have no idea what the problem is, since it looks to me like the compile/link is correct - -lgtk-3 is in the link options. Maybe Eclipse is doing something odd.

                      Keep Calm and Carry On

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #12

                      It was right at the end of the build output in the previous message:

                      /media/z/DEV_COPY_LABEL/ECLIPSE_FOLDER/2020_228/work_228/GTK_WIKI/Debug/../src/GTK_WIKI.cpp:49: undefined reference to `gtk_window_new'
                      collect2: error: ld returned 1 exit status
                      make: *** [GTK_WIKI] Error 1
                      "make all" terminated with exit code 2. Build might be incomplete.

                      10:50:37 Build Failed. 3 errors, 2 warnings. (took 2s.689ms)

                      Did you search the original which did not have any errors? I can only assume that there is an object file or library missing from the build. [edit] I have also tried to explain a number of times to OP that adding header files to a build has no effect on linker errors. [/edit]

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups