Registered Member
|
Hi there,
I am trying out an older German book called "C und Linux" by Martin Gräfe (latest edition dates back to 2010) and I am stuck when kdevelop is mentioned for the first time. My application is divided in three files which should run in the console: main.cpp
primzahl.h
and primzahl.c
While compiling main.cpp I am stuck with the error message undefined reference to `ist_primzahl(int)' It looks as if I had to set a linker flag LDFLAGS -lm in order to include the other files while compiling? I don't understand where in kdevelop this has to be done? I am using kdevelop 5 with OpenSuSe Leap 42.2. -- Thanks for your help, Felix
Last edited by fido_dido on Sat Jul 01, 2017 1:52 am, edited 1 time in total.
|
Global Moderator
|
Which build system do you use? You don't compile one of your .cpp files into the executable.
I'm working on the KDevelop IDE.
|
Registered Member
|
Is that correct: C++ IDE with CMAKE or rather Standard-Terminal? (Sorry, I am not familiar with the term "build system"? How can I find out about the translation for the German version?) Where can I set this linker flag LDFLAGS -lm in KDEVELOP5? |
Registered Member
|
Other question: I have just tried to install KDEVELOP 3. But this version dates back to 2007 and does not seem to have this "Configure Options" dialogue yet that I am desperately looking for?
I also tried KDEVELOP 4.7. But same problem: no "Configure Options" dialogue and it looks similar to current KDEVELOP 5. So which version of KDEVELOP would you recommend for a book from the year 2010? Can my problem still be solved with KDEVELOP 5? KDEVELOP 4 in a version earlier than 4.7 does not seem to be available with my OpenSuSE repositories? |
Global Moderator
|
Don't use KDevelop 3. KDevelop 4 might be an option for some cases but don't use it either. KDevelop 5 is just fine for your use case, you just have to understand how building works.
Building is handled by a tool called cmake, and that reads a file called CMakeLists.txt in your project directory. If you add a new cpp file, you have to add it to the list of files to be compiled there. You can also specify which libraries to link in that file, using target_link_libraries(), and ideally find_package() beforehand.
I'm working on the KDevelop IDE.
|
Registered Member
|
Unfortunately I did not get along with this. I just emailed the author of the book. But he is a professor now. So I think he won't have the time to support me... Eventually I will try Eclipse as an alternative and then move on with the book which still seems interesting to me, because it also covers hardware programming issues. |
Global Moderator
|
Maybe you should just read a cmake tutorial instead of emailing book authors
But you really don't even need a tutorial for that -- just add_executable(main main.cpp foo.cpp bar.cpp) target_link_libraries(main lib1 lib2)
I'm working on the KDevelop IDE.
|
Registered Member
|
Yep, finally got it working with Eclipse! Let's see what will turn out further on in the book...
|
Registered users: Bing [Bot], daret, Google [Bot], Sogou [Bot]