Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined reference to `serial::list_ports()'| #78

Closed
ejb1123 opened this issue Oct 28, 2014 · 6 comments
Closed

undefined reference to `serial::list_ports()'| #78

ejb1123 opened this issue Oct 28, 2014 · 6 comments

Comments

@ejb1123
Copy link

ejb1123 commented Oct 28, 2014

I get undefined reference to serial::list_ports()'` when i try to use the example file.
the error is thrown in this line https://github.com/wjwwood/serial/blob/master/examples/serial_example.cc#L49

vector<serial::PortInfo> devices_found = serial::list_ports();
@wjwwood
Copy link
Owner

wjwwood commented Oct 29, 2014

I can compile example locally on my Mac and the definition for that function is in the serial/serial.h header:

https://github.com/wjwwood/serial/blob/master/include/serial/serial.h#L734

Can you give more info on how you are building this?

@ejb1123
Copy link
Author

ejb1123 commented Oct 29, 2014

ej@ej-Lenovo-G510s-Touch:~/Documents/git/serial$ make
cd build && cmake -DCMAKE_INSTALL_PREFIX=/tmp/usr/local ..
-- The C compiler identification is GNU 4.8.2
-- The CXX compiler identification is GNU 4.8.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Using CATKIN_DEVEL_PREFIX: /home/ej/Documents/git/serial/build/devel
-- Using CMAKE_PREFIX_PATH: 
-- Found PythonInterp: /usr/bin/python (found version "2.7.6") 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/ej/Documents/git/serial/build/test_results
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.9
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ej/Documents/git/serial/build
cd build && make
make[1]: Entering directory `/home/ej/Documents/git/serial/build'
make[2]: Entering directory `/home/ej/Documents/git/serial/build'
make[3]: Entering directory `/home/ej/Documents/git/serial/build'
Scanning dependencies of target serial
make[3]: Leaving directory `/home/ej/Documents/git/serial/build'
make[3]: Entering directory `/home/ej/Documents/git/serial/build'
[ 25%] Building CXX object CMakeFiles/serial.dir/src/serial.cc.o
[ 50%] Building CXX object CMakeFiles/serial.dir/src/impl/unix.cc.o
[ 75%] Building CXX object CMakeFiles/serial.dir/src/impl/list_ports/list_ports_linux.cc.o
Linking CXX shared library devel/lib/libserial.so
make[3]: Leaving directory `/home/ej/Documents/git/serial/build'
[ 75%] Built target serial
make[3]: Entering directory `/home/ej/Documents/git/serial/build'
Scanning dependencies of target serial_example
make[3]: Leaving directory `/home/ej/Documents/git/serial/build'
make[3]: Entering directory `/home/ej/Documents/git/serial/build'
[100%] Building CXX object CMakeFiles/serial_example.dir/examples/serial_example.cc.o
Linking CXX executable devel/lib/serial/serial_example
make[3]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target serial_example
make[2]: Leaving directory `/home/ej/Documents/git/serial/build'
make[1]: Leaving directory `/home/ej/Documents/git/serial/build'

@wjwwood
Copy link
Owner

wjwwood commented Oct 29, 2014

@ejb1123 that looks like a successful build to me 😄

You can try make test to make sure stuff builds and run against it.

@ejb1123
Copy link
Author

ejb1123 commented Oct 29, 2014

ej@ej-Lenovo-G510s-Touch:~/Documents/git/serial$ make test 
cd build && cmake -DCMAKE_INSTALL_PREFIX=/tmp/usr/local ..
-- Using CATKIN_DEVEL_PREFIX: /home/ej/Documents/git/serial/build/devel
-- Using CMAKE_PREFIX_PATH: 
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/ej/Documents/git/serial/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.6.9
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ej/Documents/git/serial/build
cd build && make run_tests
make[1]: Entering directory `/home/ej/Documents/git/serial/build'
make[2]: Entering directory `/home/ej/Documents/git/serial/build'
make[3]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[ 14%] Built target gtest
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[ 28%] Built target gtest_main
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[ 71%] Built target serial
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[ 85%] Built target serial-test-timer
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[ 85%] Built target clean_test_results
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target serial-test
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target tests
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
-- run_tests.py: execute commands
  /home/ej/Documents/git/serial/build/devel/lib/serial/serial-test-timer --gtest_output=xml:/home/ej/Documents/git/serial/build/test_results/serial/gtest-serial-test-timer.xml
[==========] Running 2 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 2 tests from timer_tests
[ RUN      ] timer_tests.short_intervals
[       OK ] timer_tests.short_intervals (937 ms)
[ RUN      ] timer_tests.overlapping_long_intervals
[       OK ] timer_tests.overlapping_long_intervals (1011 ms)
[----------] 2 tests from timer_tests (1948 ms total)

[----------] Global test environment tear-down
[==========] 2 tests from 1 test case ran. (1949 ms total)
[  PASSED  ] 2 tests.
-- run_tests.py: verify result "/home/ej/Documents/git/serial/build/test_results/serial/gtest-serial-test-timer.xml"
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target _run_tests_serial_gtest_serial-test-timer
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
-- run_tests.py: execute commands
  /home/ej/Documents/git/serial/build/devel/lib/serial/serial-test --gtest_output=xml:/home/ej/Documents/git/serial/build/test_results/serial/gtest-serial-test.xml
[==========] Running 4 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 4 tests from SerialTests
[ RUN      ] SerialTests.readWorks
[       OK ] SerialTests.readWorks (1 ms)
[ RUN      ] SerialTests.writeWorks
[       OK ] SerialTests.writeWorks (0 ms)
[ RUN      ] SerialTests.timeoutWorks
[       OK ] SerialTests.timeoutWorks (249 ms)
[ RUN      ] SerialTests.partialRead
[       OK ] SerialTests.partialRead (250 ms)
[----------] 4 tests from SerialTests (500 ms total)

[----------] Global test environment tear-down
[==========] 4 tests from 1 test case ran. (500 ms total)
[  PASSED  ] 4 tests.
-- run_tests.py: verify result "/home/ej/Documents/git/serial/build/test_results/serial/gtest-serial-test.xml"
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target _run_tests_serial_gtest_serial-test
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target _run_tests_serial_gtest
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target _run_tests_serial
make[4]: Entering directory `/home/ej/Documents/git/serial/build'
make[4]: Leaving directory `/home/ej/Documents/git/serial/build'
[100%] Built target run_tests
make[3]: Leaving directory `/home/ej/Documents/git/serial/build'
make[2]: Leaving directory `/home/ej/Documents/git/serial/build'
make[1]: Leaving directory `/home/ej/Documents/git/serial/build'
ej@ej-Lenovo-G510s-Touch:~/Documents/git/serial$ 

@wjwwood
Copy link
Owner

wjwwood commented Oct 29, 2014

That looks like a success to me too, maybe you had an old version of the serial library lying around and when you compile it found the new header, but when you tried to link you got the old version of the library.

Either was I don't see any issue with the output you posted above.

@ejb1123
Copy link
Author

ejb1123 commented Oct 29, 2014

Thanks for the help i got it working in code blocks.
I had to set the the linker setting by pointing it to /usr/local/lib/libserial.so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants