我尝试通过CodeBlocks编译这些文件,我从这里下载了这些文件:
https://git.gnome.org/browse/gtkmm-documentation/tree/examples/book/frame?h=master
当我尝试使用代码块编译它时,我得到了错误:
main.cpp | 8 |对`ExampleWindow :: ExampleWindow()'|
的未定义引用
但是我从它工作的终端编译它:
g++ main.cc examplewindow.cc -o simple `pkg-config gtkmm-3.0 --cflags --libs`
有没有想法如何让代码块编译两个源文件?
-------------- Build:在youtube中调试(编译器:GNU GCC编译器)---------------
g ++ -Wall -fexceptions -g -std = gnu ++ 11 -pthread -I / usr / include / gtkmm-3.0 -I / usr / lib / x86_64-linux-gnu / gtkmm-3.0 / include -I / usr / include / atkmm-1.6 -I / usr / include / giomm-2.4 -I /usr/lib/x86_64-linux-gnu/giomm-2.4/include -I / usr / include / pangomm-1.4 -I / usr / lib / x86_64-linux-gnu / pangomm-1.4 / include -I / usr / include /gtk-3.0 -I / usr / include / cairomm-1.0 -I / usr / lib / x86_64-linux-gnu / cairomm-1.0 / include -I / usr / include / gdk-pixbuf-2.0 -I / usr / include /gtk-3.0/unix-print -I / usr / include / gdkmm-3.0 -I / usr / lib / x86_64-linux-gnu / gdkmm-3.0 / include -I / usr / include / atk-1.0 -I / usr /include/glibmm-2.4 -I / usr / lib / x86_64-linux-gnu / glibmm-2.4 / include -I / usr / include / glib-2.0 -I / usr / lib / x86_64-linux-gnu / glib-2.0 / include -I / usr / include / sigc ++ - 2.0 -I / usr / lib / x86_64-linux-gnu / sigc ++ - 2.0 / include -I / usr / include / pango-1.0 -I / usr / include / cairo -I / usr / include / pixman-1 -I / usr / include / freetype2 -I / usr / include / libpng12 -I / usr / include / at-spi2-atk / 2.0 -I / usr / include / gio-unix-2.0 / -I / usr / include / harfbuzz -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm-2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 -I / usr / include / -I / usr / lib / x86_64-linux-gnu / -c /home/bahaa/programming/c++/youtube/main.cpp -o obj / Debug / main.o g ++ -o bin / Debug / youtube obj / Debug / main.o -L / usr / lib / mysql -lmysqlclient -lgtkmm-3.0 -latkmm-1.6 -lgdkmm-3.0 -lgiomm-2.4 -lpangomm-1.4 -lgtk-3 -lglibmm -2.4 -lcairomm-1.0 -lgdk-3 -latk-1.0 -lgio-2.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo-gobject -lpango-1.0 -lcairo -lsigc-2.0 -lgobject-2.0 -lglib-2.0 obj / Debug / main.o:在函数
main': /home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow :: ExampleWindow()' /home/bahaa/programming/c++/youtube/main.cpp:8:未定义引用ExampleWindow::~ExampleWindow()' /home/bahaa/programming/c++/youtube/main.cpp:8: undefined reference to
ExampleWindow :: ~OampleWindow()'collect2:error:ld返回1退出 status进程终止,状态为1(0分,1秒)3 错误,0警告(0分钟,1秒)
https://www.youtube.com/watch?v=3v3koVNb7hU&feature=youtu.be
答案 0 :(得分:0)
您在终端中输入的命令与命令代码块正在执行的命令完全不同,因此它执行不同的操作是逻辑。
但是在undefined reference
的情况下,通常意味着您忘记了include
某个地方。声明/定义ExampleWindow
在哪里?它是否包含在您的main
中,通过您正在做的两个包含中的一个?