1

I am trying to establish a serial connection between arduino and a computer running ubuntu 14.04.

I am using this library https://github.com/wjwwood/serial

There are several dependencies, which I hoped to avoid because I am very new to this and wanted to keep this as basic as possible. Apparently I was not the only one, and the project owner has replied with this https://github.com/wjwwood/serial/issues/52

I used that CMakeLists.txt on the example provided in serial/examples/serial_example.cc (cannot post direct link due to restrictions, but it is github)

These are the steps I took

  1. Place the CMakeList.txt from above into /serial/ library, replacing the original one
  2. Place serial_example.cc into /serial/src/ directory and rename it to "my_program.cpp"
  3. Open gnome-terminal and navigate to /serial/ folder
  4. In terminal execute "mkdir build" and enter that directory
  5. In terminal execute "cmake ../"
  6. In terminal execute "make"

    [ 66%] Built target serial Linking CXX executable my_program CMakeFiles/my_program.dir/src/my_program.cpp.o: In function enumerate_ports()': my_program.cpp:(.text+0x32): undefined reference toserial::list_ports()' collect2: error: ld returned 1 exit status make[2]: * [my_program] Error 1 make1: * [CMakeFiles/my_program.dir/all] Error 2 make: *** [all] Error 2

I have tried running make with sudo, but did not have success

This is the content of build directory after "cmake ../"

total 188
-rw-rw-r-- 1 dundua dundua  12080 maj 24 13:49 CMakeCache.txt
drwxrwxr-x 7 dundua dundua   4096 maj 24 13:51 CMakeFiles
-rw-rw-r-- 1 dundua dundua   1630 maj 24 13:49 cmake_install.cmake
-rw-rw-r-- 1 dundua dundua 162888 maj 24 13:49 libserial.a
-rw-rw-r-- 1 dundua dundua   6837 maj 24 13:49 Makefile

After some search, it appears that I am running into a similar issue that is described in github, as issue #78, and using Code::Blocks to manually link to a compiled libserial.so in another directory seems to work, but I would like to know how to accomplish this without Code::Blocks since I will need to merge my code with another cmake project

m.s.
  • 16,063
  • 7
  • 53
  • 88
Lord Melon
  • 11
  • 2
  • Why did you think using `sudo` would solve an ["undefined reference" error](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) ? If you compare your `CMakeLists.txt` with the original, you'll see you aren't compiling the `list_ports_.cc` that contains the missing function. – Leiaz May 25 '15 at 14:51
  • You're right, Leiaz, that was the problem. Apparently the cpp example was published a year after the cmake example. I just assumed I was doing something wrong while compiling – Lord Melon May 26 '15 at 22:37

0 Answers0