Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 09:30 Go to next message
Julia Ben is currently offline Julia BenFriend
Messages: 2
Registered: January 2021
Junior Member
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 14:05 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

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 07:12 Go to previous messageGo to next message
zhao xiaolong is currently offline zhao xiaolongFriend
Messages: 5
Registered: November 2020
Junior Member
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 08:03]

Report message to a moderator

Re: How to solve "undefined reference to 'wiringPiSetup'" [message #1837351 is a reply to message #1837348] Thu, 28 January 2021 09:03 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 16
Registered: January 2021
Junior Member
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 10:00 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

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 10:03]

Report message to a 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: Thu Apr 25 15:38:14 GMT 2024

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

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

Back to the top