arduino-cmake / Arduino-CMake-NG

CMake-Based framework for Arduino platforms
MIT License
138 stars 39 forks source link

Problem when with determining link language. #70

Closed rzajac closed 5 years ago

rzajac commented 5 years ago

OS: Linux Distribution: Ubuntu OS Version: 18.04.1 Platform: Arduino Platform SDK Version: [Arduino SDK version 1.8.8]

I get this error when trying to generate Makefile. Not sure how to debug it.

/home/thor/bin/clion-2018.2.4/bin/cmake/linux/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=cmake/Arduino-Toolchain.cmake -G "CodeBlocks - Unix Makefiles" /home/thor/Documents/from-scratch/software/webcam/arduino/encoder
-- Arduino SDK version 1.8.8: /home/thor/bin/arduino
-- Determined Platform Header: /home/thor/bin/arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: /home/thor/bin/arduino
-- Determined Platform Header: /home/thor/bin/arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: /home/thor/bin/arduino
-- Determined Platform Header: /home/thor/bin/arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Configuring done
CMake Error: Cannot determine link language for target "nano_atmega328old_core_lib".
CMake Error: CMake can not determine linker language for target: nano_atmega328old_core_lib
-- Generating done
-- Build files have been written to: /home/thor/Documents/from-scratch/software/webcam/arduino/encoder/cmake-build-debug

My CMakeLists.txt file:

cmake_minimum_required(VERSION 3.8.2)

project(e2)

# Call a framework utility function, passing it information about the hardware board that will be used - This function returns a structure known only to the framework
get_board_id(board_id nano atmega328old)

# Create an executable suitable for Arduino using CMake-style target-creation
add_arduino_executable(e2 ${board_id} encoder.cpp)
# Upload the created target through a connected Serial Port (Where your board is connected to)
upload_arduino_target(e2 "${board_id}" /dev/ttyUSB0)
rzajac commented 5 years ago

I think It was something wrong with my system or packages. I have solved it by removing all system packaged dealing with AVR then removed Arduino SDK and installed it again.

Changed the CMakeLists.txt file to:

cmake_minimum_required(VERSION 3.8)
project(my_blinky LANGUAGES C CXX ASM)

get_board_id(board_id nano atmega328old)

add_arduino_executable(${PROJECT_NAME} ${board_id} main.cpp)
upload_arduino_target(${PROJECT_NAME} "${board_id}" /dev/ttyUSB0)

Created minimum main.cpp file:

#include <Arduino.h>

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(1000);                    
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
}

Put toolchain files in toolchain directory so my project directory structure looks like this:

$ tree -d -L 1
.
├── build
├── CMakeLists.txt
├── main.cpp
└── toolchain
    ├── Arduino-Toolchain.cmake
    └── Platform

and did:

$ cd build
$ rm -rf ./* && ARDUINO_SDK_PATH=/usr/share/arduino cmake -DCMAKE_TOOLCHAIN_FILE=toolchain/Arduino-Toolchain.cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/share/arduino/hardware/tools/avr/bin/avr-gcc
-- Arduino SDK version 1.8.8: /usr/share/arduino
-- Determined Platform Header: /usr/share/arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: /usr/share/arduino
-- Determined Platform Header: /usr/share/arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Check for working C compiler: /usr/share/arduino/hardware/tools/avr/bin/avr-gcc
-- Check for working C compiler: /usr/share/arduino/hardware/tools/avr/bin/avr-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Arduino SDK version 1.8.8: /usr/share/arduino
-- Determined Platform Header: /usr/share/arduino/hardware/arduino/avr/cores/arduino/Arduino.h
-- Check for working CXX compiler: /usr/share/arduino/hardware/tools/avr/bin/avr-g++
-- Check for working CXX compiler: /usr/share/arduino/hardware/tools/avr/bin/avr-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/thor/Documents/from-scratch/software/webcam/arduino/encoder/build

This time cmake did not report any errors but when I tried to make the project I got an error about missing reference to main. I will create separate ticket for it.

MrPointer commented 5 years ago

@rzajac Hi, sorry for the delay, been pretty busy lately. Well, first of all I'm glad to hear that the initial problem was related to your system setup. Now about that 2nd error, before you open a separate issue for it, you should know that Arduino generates its' own main.cpp file, which is why you can't create one of your own. Try to name it differently and see if the problem solves 😃

rzajac commented 5 years ago

@MrPointer Thanks for helping. Your tip worked! You may close the issue.