I'm trying to build an Arduino example without using its IDE. My OS is Windows 8.1 and I'm using the last version of CMake (2.8.12.2) and MinGW (GNU Make 3.82.90).
I downloaded the Arduino CMakeLists and I learned all about make/upload
any firmware in my Arduino. I'm using Arduino UNO.
Then, if I modify the CMakeLists saved in ~/arduino-cmake-master/example/CMakeLists.txt
(arduino-cmake-master is the repository folder) to build the WiFi example WiFiWebClient too:
...
#Add the WiFi example -> WiFiWebClient
generate_arduino_example(wifi_example
LIBRARY WiFi
EXAMPLE WiFiWebClient)
...
And execute:
$ cmake -G "MinGW Makefiles"
...
CMake Warning (dev) in example/CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "uno_example" has an INTERFACE_LINK_LIBRARIES property. This should
be preferred as the source of the link interface for this library but
because CMP0022 is not set CMake is ignoring the property and using the
link implementation as the link interface instead.
INTERFACE_LINK_LIBRARIES:
uno_CORE;uno_example;uno_Wire
Link implementation:
uno_CORE;uno_Wire
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) in example/CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "uno_Wire" has an INTERFACE_LINK_LIBRARIES property. This should be
preferred as the source of the link interface for this library but because
CMP0022 is not set CMake is ignoring the property and using the link
implementation as the link interface instead.
INTERFACE_LINK_LIBRARIES:
uno_CORE;uno_Wire
Link implementation:
uno_CORE
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) in example/CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "uno_SPI" has an INTERFACE_LINK_LIBRARIES property. This should be
preferred as the source of the link interface for this library but because
CMP0022 is not set CMake is ignoring the property and using the link
implementation as the link interface instead.
INTERFACE_LINK_LIBRARIES:
uno_CORE;uno_SPI
Link implementation:
uno_CORE
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) in example/CMakeLists.txt:
Policy CMP0022 is not set: INTERFACE_LINK_LIBRARIES defines the link
interface. Run "cmake --help-policy CMP0022" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
Target "uno_WiFi" has an INTERFACE_LINK_LIBRARIES property. This should be
preferred as the source of the link interface for this library but because
CMP0022 is not set CMake is ignoring the property and using the link
implementation as the link interface instead.
INTERFACE_LINK_LIBRARIES:
uno_CORE;uno_WiFi
Link implementation:
uno_CORE
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: ~/arduino-cmake-master
Later I execute:
$ mingw32-make
...
Linking CXX static library libuno_WiFi.a
[ 89%] Built target uno_WiFi
Scanning dependencies of target wifi_example
[ 92%] Building CXX object example/CMakeFiles/wifi_example.dir/wifi_example_WiFiWebClient.cpp.obj
Linking CXX executable wifi_example.elf
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::status()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:160: undefined reference to `ServerDrv::getClientState(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::stop()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:131: undefined reference to `ServerDrv::stopClient(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::peek()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:117: undefined reference to `ServerDrv::getData(unsigned char, unsigned char*, unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::read()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:101: undefined reference to `ServerDrv::getData(unsigned char, unsigned char*, unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::read(unsigned char*, unsigned int)':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:107: undefined reference to `ServerDrv::getDataBuf(unsigned char, unsigned char*, unsigned int*)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::available()':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:90: undefined reference to `ServerDrv::availData(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::write(unsigned char const*, unsigned int)':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:73: undefined reference to `ServerDrv::sendData(unsigned char, unsigned char const*, unsigned int)'
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:78: undefined reference to `ServerDrv::checkDataSent(unsigned char)'
libuno_WiFi.a(WiFiClient.cpp.obj): In function `WiFiClient::connect(IPAddress, unsigned int)':
C:\Program Files\Arduino\libraries\WiFi/WiFiClient.cpp:36: undefined reference to `ServerDrv::startClient(unsigned long, unsigned int, unsigned char, unsigned char)'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::hostByName(char const*, IPAddress&)':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:228: undefined reference to `WiFiDrv::getHostByName(char const*, IPAddress&)'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::status()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:223: undefined reference to `WiFiDrv::getConnectionStatus()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::RSSI()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:181: undefined reference to `WiFiDrv::getCurrentRSSI()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::SSID()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:169: undefined reference to `WiFiDrv::getCurrentSSID()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::localIP()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:149: undefined reference to `WiFiDrv::getIpAddress(IPAddress&)'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::begin(char*, char const*)':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:87: undefined reference to `WiFiDrv::wifiSetPassphrase(char*, unsigned char, char const*, unsigned char)'
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:92: undefined reference to `WiFiDrv::getConnectionStatus()'
libuno_WiFi.a(WiFi.cpp.obj): In function `WiFiClass::init()':
C:\Program Files\Arduino\libraries\WiFi/WiFi.cpp:22: undefined reference to `WiFiDrv::wifiDriverInit()'
example\CMakeFiles\wifi_example.dir\build.make:95: recipe for target 'example/wifi_example.elf' failed
mingw32-make[2]: *** [example/wifi_example.elf] Error 1
CMakeFiles\Makefile2:748: recipe for target 'example/CMakeFiles/wifi_example.dir/all' failed
mingw32-make[1]: *** [example/CMakeFiles/wifi_example.dir/all] Error 2
Makefile:74: recipe for target 'all' failed
mingw32-make: *** [all] Error 2
The problem is the Arduino.cmake because it's not linking correctly with the library WiFi, but it links with the Wire library.
Anyone knows why that warning appears and why Wire links ok but WiFi doesn't?
Thanks!
Note: I'm using original code which is in the repository example, I've not modified this one.
CMakeLists.txt
? Also, did you modify something else in this file?make
).generate_arduino_library(WiFi...)
first, defining all headers and source files included in WiFi directory? Indeed, I don't think cmake will be able to build the library properly as it should not be able to find files in subdirectoryutility
: these are the files that contain definitions thatmingw32-make
is complaining about.set(WiFi_RECURSE True)
; it tells cmake to compile all files including those in subdirectories of the WiFi library.