Skip to main content



      Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » How to solve "undefined reference to 'wiringPiSetup'"(undefined reference to 'wiringPiSetup')
How to solve "undefined reference to 'wiringPiSetup'" [message #1837301] Wed, 27 January 2021 04:30 Go to next message
Eclipse UserFriend
I created my own SIFB, and C language is used for programming. My code is in the attachment. An error occurred at compile time. Tip me "undefined reference to 'wiringPiSetup". wiringPi. h and pcf8591.h are localed in/usr/include.


I think "cmakelists.txt" may have problem. How to write cmakelists. txt?
Or how to solve the problem?
Please give me a hand!
Re: How to solve "undefined reference to 'wiringPiSetup'" [message #1837322 is a reply to message #1837301] Wed, 27 January 2021 09:05 Go to previous messageGo to next message
Eclipse UserFriend
It looks like you also have to specifiy the wiringPi library to be linked to your self built forte. You can do this by modifying your cmakelist.txt. As example you can have a look at the mqtt paho directory.
Re: How to solve "undefined reference to 'wiringPiSetup'" [message #1837348 is a reply to message #1837322] Thu, 28 January 2021 02:12 Go to previous messageGo to next message
Eclipse UserFriend
Dear sir, when I write

forte_add_handler(pcf8591 /usr/include/pcf8591)

it will add the current directory where cmakelists.txt is located, which is "forte/ext_modules/test/usr/include". Then it can't find pcf8591. Do you know how to solve this problem? Thank you very much!

My cmakelists.txt:

forte_add_module(RECEIVE_VOLTAGE "Example test module")
forte_add_handler(pcf8591 /usr/include/pcf8591)
forte_add_handler(wiringPi /usr/include/wiringPi)
forte_add_sourcefile_hcpp(voltage_receive)


The fault of cmake-gui:

CMake Error at src/CMakeLists.txt:261 (add_library):
Cannot find source file:
/home/zxl/FORTEdev/ext_modules/Receive_Voltage/usr/include/pcf8591.h
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
CMake Error at src/CMakeLists.txt:261 (add_library):
No SOURCES given to target: FORTE_LITE

[Updated on: Thu, 28 January 2021 03:03] by Moderator

Re: How to solve "undefined reference to 'wiringPiSetup'" [message #1837351 is a reply to message #1837348] Thu, 28 January 2021 04:03 Go to previous messageGo to next message
Eclipse UserFriend
forte_add_handler is used only if you are extending the Handler class, which it doesn't to be your case.

As Alois said, you need to add the wiringPi library to the compilation

Your CMakeLists.txt should look something like:

forte_add_module(RECEIVE_VOLTAGE "Example test module")
forte_add_include_system_directories(/usr/include/)
forte_add_sourcefile_hcpp(voltage_receive)
forte_add_link_library(wiringPi)
Re: How to solve "undefined reference to 'wiringPiSetup'" [message #1837354 is a reply to message #1837348] Thu, 28 January 2021 05:00 Go to previous message
Eclipse UserFriend
For adding a library to be linked to your forte you need to use the forte_add_link_library() option. There you specify your lib*.a or lib*.so whatever you have.

googled a bit and it should be forte_add_link_library(wiringPi).
Maybe you have to specify the location of your wiringPi lib file with forte_add_link_directories(xxxx)

[Updated on: Thu, 28 January 2021 05:03] by Moderator

Previous Topic:How to solve "undefined reference to 'wiringPiSetup'"
Next Topic:Create Forte Boot-files in 4Diac IDE v. 1.13.1
Goto Forum:
  


Current Time: Sun Jul 20 12:59:47 EDT 2025

Powered by FUDForum. Page generated in 0.04848 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top