Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 6 months ago.
Conditional Library compilation
I have two libraries : SPI_TFT and SPI_TFT_ILI9341. I need to use one *or* the other depending on the type of display controller a user has. I tried adding #ifdef #else around the #include statements so I only reference one in the code, but the compiler still compiles both libraries and gives me multiple definition errors (L6200E). How can I tell the compiler not to compile a library included in a project?
Presently I have to maintain two forks (one for each type of LCD display controller):
http://mbed.org/users/TickTock/code/CANary
http://mbed.org/users/TickTock/code/CANary_9341
Here is a test area showing the problem when I try to create one project with both libraries:
http://mbed.org/users/TickTock/code/CANary_9341_test/
I don't even reference the SPI_TFT library at all in my code but it still tries to compile causing the linker error. I am looking for a way to tell the compiler to ignore one or the other.
1 Answer
10 years, 6 months ago.
Lazy Solution
My lazy solution would be this: /media/uploads/yoonghm/canary.zip
These are the changes:
- Combine SPI_TFTx2 and SPI_TFTx2_ILI9341 folders into one. Resolve the differences.
- Update files in TOUCH_TFTx2 folder to derive
TOUCH_TFTx2
class fromSPI_TFTx2
orSPI_TFTx2_IFI9341
. This can be controlled during pre-compilation stage usingprecompile.h
in the TOUCH_TFTx2 folder. The file is also needed inmain.cpp
. The constructors forTOUCH_TFTx2
forSPI_TFTx2
andSPI_TFTx2_IFI9341
are a bit difference. So the code is quite messy.
Better Solution
Define TOUCH_TFTx2
as virtual class. Implement the details in the concrete derived class such as SPI_TFTx2
and SPI_TFTx2_IFI9341
Please don't spam questions area :-) What if you share your code, that would be for us a good starting point what you got a the moment.
posted by Martin Kojtal 12 May 2014I added links to the projects I am facing this problem with. Not following the spam comment. Is there another, smaller distribution area, I should be using to ask questions?
posted by Tick Tock 12 May 2014