Closed hradec closed 4 years ago
I was able to "fix" the "SoftwareSerial" undefined references by adding
ifeq ($(TMC), 1)
LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
+ LIB_CXXSRC += SoftwareSerial.cpp
endif
to the Makefile. So it does seems like the Makefile should be adding this source but it isn't. After that change, my error message when down to just "undefined" in the TMC2208Stepper.cpp:
CXX src/libs/hex_print_routines.cpp
CXX src/libs/crc16.cpp
CXX src/libs/L64XX/L64XX_Marlin.cpp
CXX applet/Marlin.elf
applet/arduino/TMC2208Stepper.o: In function `TMC2208Stepper::TMC2208Stepper(unsigned int, unsigned int, float, unsigned char)':
TMC2208Stepper.cpp:(.text._ZN14TMC2208StepperC2Ejjfh+0xb4): undefined reference to `operator new(unsigned int)'
applet/arduino/TMC2208Stepper.o: In function `TMC2208Stepper::write(unsigned char, unsigned long)':
TMC2208Stepper.cpp:(.text._ZN14TMC2208Stepper5writeEhm+0xc2): undefined reference to `SSwitch::active()'
applet/arduino/TMC2208Stepper.o: In function `TMC2208Stepper::read(unsigned char)':
TMC2208Stepper.cpp:(.text._ZN14TMC2208Stepper4readEh+0x146): undefined reference to `SSwitch::active()'
collect2: error: ld returned 1 exit status
make: *** [Makefile:878: applet/Marlin.elf] Error 1
Now I'm a bit confused because it doesn't seem like just missing source code files now, but actually something missing in the code itseld?!?! not sure...
The symbol _ZN14TMC2208Stepper5writeEhm
translates to TMC2208Stepper::TMC2208Stepper(unsigned int, unsigned int, float, unsigned char)
, which is the class defined by TMC2208Stepper.cpp.
I'll go dig into TMC2208Stepper.cpp now, but if someone out there already known what this error is, I would really appreciate!
Off course I'm assuming there's not error in the code, but something missing in the Makefile, since no one is having this problem unless me using the Makefile, right?
ok... I fixed another little bit by adding another missing file, this time from TMCStepper Library:
ifeq ($(TMC), 1)
LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
+ LIB_CXXSRC += SoftwareSerial.cpp SERIAL_SWITCH.cpp
endif
SERIAL_SWITCH.cpp fixes the other couple of undefined SSwitch in the middle of TMC2208Stepper.cpp source code, but there's still one left:
CXX src/libs/hex_print_routines.cpp
CXX src/libs/crc16.cpp
CXX src/libs/L64XX/L64XX_Marlin.cpp
CXX applet/Marlin.elf
applet/arduino/TMC2208Stepper.o: In function `TMC2208Stepper::TMC2208Stepper(unsigned int, unsigned int, float, unsigned char)':
TMC2208Stepper.cpp:(.text._ZN14TMC2208StepperC2Ejjfh+0xb4): undefined reference to `operator new(unsigned int)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:878: applet/Marlin.elf] Error 1
not sure what this new(unsigned int)
is now... :(
ok... I finally figured out the problem:
ifeq ($(TMC), 1)
LIB_CXXSRC += TMCStepper.cpp COOLCONF.cpp DRV_STATUS.cpp IHOLD_IRUN.cpp CHOPCONF.cpp GCONF.cpp PWMCONF.cpp DRV_CONF.cpp DRVCONF.cpp DRVCTRL.cpp DRVSTATUS.cpp ENCMODE.cpp RAMP_STAT.cpp SGCSCONF.cpp SHORT_CONF.cpp SMARTEN.cpp SW_MODE.cpp SW_SPI.cpp TMC2130Stepper.cpp TMC2208Stepper.cpp TMC2209Stepper.cpp TMC2660Stepper.cpp TMC5130Stepper.cpp TMC5160Stepper.cpp
+ LIB_CXXSRC += SoftwareSerial.cpp SERIAL_SWITCH.cpp new.cpp
endif
It seems we need to include arduinos new.cpp
to create the object for the new
c++ functionality used by TMCStepper library. I guess arduino IDE adds that by default, as well as SoftwareSerial.cpp.
Anyhow, the problem with the Makefile when building for RAMPS with TMC2208, is the 3 missing .cpp files above.
I'll make a pull request with this fix.
But if someone runs into this type of problem in the future, the solution is documented here anyway.
@hradec: The Makefile seems to have fallen out of favor in the Marlin community. I am the only one who maintains it for my own personal use and I don't use a TMC2208 :) But I do appreciate the effort you put into it and I do appreciate the PR.
@hradec still an issue?
Lack of Activity This issue is being closed due to lack of activity. If you have solved the issue, please let us know how you solved it. If you haven't, please tell us what else you've tried in the meantime, and possibly this issue will be reopened.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Bug Description
So, I'm trying to build 2.0.x using the Makefile, and I keep getting a link error with "undefined reference", as follow:
My Configurations
config.zip
Steps to Reproduce
Just run "make" with my configuration files.
Expected behavior: The build to finish successfully.
Actual behavior: It fails the build when building Marlin.elf
Additional Information
I'm using Arduino 1.8.2 downloaded from Arduino website. I tried on booth armv71(raspberry pi 3) and x86_64 platforms and got the same result.
I'm also using the latest TMCStepper library released on github. (0.6.2)