Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Undefined reference to countPulseASM when using pulseIn function #75

Open
dominicap opened this issue Feb 26, 2019 · 8 comments
Open

Undefined reference to countPulseASM when using pulseIn function #75

dominicap opened this issue Feb 26, 2019 · 8 comments
Assignees
Labels
bug Potential bug in code priority: minor Minor priority - Probably won't be implemented soon

Comments

@dominicap
Copy link

OS: macOS
OS Version: 10.14.2
Platform: Arduino
Platform SDK Version: [Arduino SDK version 1.8.8]

When trying to use the built in "pulseIn" function, I receive an undefined reference to `countPulseASM'

Build Output:

====================[ Build | auto_car | Default ]==============================
/usr/local/bin/cmake --build /Users/Dominic/Desktop/auto-car/build --target auto_car -- -j 4
[ 92%] Built target mega_atmega2560_core_lib
[ 96%] Linking CXX executable auto_car.elf
/var/folders/vh/n3x031n547v4qhvxs1p_wtf00000gn/T//ccNcSGia.ltrans0.ltrans.o: In function `pulseIn':
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_pulse.c:46: undefined reference to `countPulseASM'
collect2: error: ld returned 1 exit status
make[3]: *** [auto_car.elf] Error 1
make[2]: *** [CMakeFiles/auto_car.dir/all] Error 2
make[1]: *** [CMakeFiles/auto_car.dir/rule] Error 2
make: *** [auto_car] Error 2

CMakeLists.txt:

cmake_minimum_required(VERSION 3.13.3)
project(auto_car LANGUAGES C CXX)

get_board_id(board_id mega atmega2560)

add_arduino_executable(auto_car ${board_id} src/auto_car.cpp)

Source file:

#include <Arduino.h>

#define PIN 14

void setup()
{
    // Setup
}

void loop()
{
    pulseIn(PIN, HIGH, 40000);
}

I believe this might be related to issue 364 in the Arduino-Makefile community and issue 23 from the original Arduino CMake Build System.

Help would be appreciated, thanks!

@MrPointer
Copy link
Member

MrPointer commented Feb 26, 2019

Quick guess: Try to append ASM to the project's languages definition.
Your project() call should look like this: project(auto_car LANGUAGES C CXX ASM)

@dominicap
Copy link
Author

@MrPointer Yup, that was it, thanks again!

@cebas
Copy link

cebas commented Apr 26, 2019

@MrPointer I had this problem too, and fixed with your workaround. Thanks!
But I think this is still a bug, because the ASM source belongs to the core, not to my project, and it should have been discovered when building the core lib.

@MrPointer
Copy link
Member

@cebas You're probably right - I guess it has something to do with CMake's generator expressions, but I'm not entirely sure.
I'm re-opening this until we have a concrete answer.

@MrPointer MrPointer reopened this Apr 27, 2019
@MrPointer MrPointer added bug Potential bug in code priority: minor Minor priority - Probably won't be implemented soon labels Apr 27, 2019
@MrPointer MrPointer self-assigned this Apr 27, 2019
@dev10
Copy link

dev10 commented Feb 20, 2020

In case someone else is having the same issue with Arduino 1.8.11, I had to make it look like the following:

in CMakeLists.txt line 8:

project(${PROJECT_NAME} LANGUAGES C CXX ASM)

in cmake/Platform/Arduino.cmake starting line 1477:

function(find_sources VAR_NAME LIB_PATH RECURSE)
    set(FILE_SEARCH_LIST
        ${LIB_PATH}/*.cpp
        ${LIB_PATH}/*.c
        ${LIB_PATH}/*.S
...

@MrPointer
Copy link
Member

@dev10 I'm sorry but there's no such line in the file cmake/Platform/Arduino.cmake.
In fact, this file only contains 40 lines.

You're probably confusing with the original arduino-cmake project, which this project continues since it's the only version of this project that had everything written in a single file (indeed Arduino.cmake)

@brandentimm
Copy link

I had the same issue that was fixed by @dev10's suggestion from the Arduino.cmake file generated by the CLion Arduino plugin, just as a general tip/FYI for other users stumbling across this.

@allyo-dmytro-smyk
Copy link

@dev10 that helped a lot, thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Potential bug in code priority: minor Minor priority - Probably won't be implemented soon
Projects
None yet
Development

No branches or pull requests

6 participants