Author Topic: How to link libraries  (Read 5735 times)

Offline zhezhoo

  • Single posting newcomer
  • *
  • Posts: 2
How to link libraries
« on: March 16, 2022, 11:02:08 pm »
I'm working on a project involving an ATMEGA microcontroller and WS2812 LEDs, but I don't seem to be able to figure out how to include Adafruit_NeoPixel library -that I've downloaded from github- in my project. Can anybody please tell me how it is done?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3255
Re: How to link libraries
« Reply #1 on: March 17, 2022, 12:35:35 am »
Are you using the Arduino framework, or do you use only AVR gcc?
Can you give a link to the library?

What exactly is your problem? Can you describe it a bit in detail?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7298
    • My Best Post
Re: How to link libraries
« Reply #2 on: March 17, 2022, 04:06:24 am »
My guess is create an C++ Code::Block project then add the example/test code for the library to it.
Then I would add the library source files to the project starting with the C++ library and header files as needed to get rid of the build errors.

But, the above is only valid if you are using GCC directly instead of using an Arduino framework/build system.

If you are using an Arduino build system I would suggest asking on a website supporting the Arduino build system.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline zhezhoo

  • Single posting newcomer
  • *
  • Posts: 2
Re: How to link libraries
« Reply #3 on: March 17, 2022, 10:40:09 am »
I'm using AVR GCC. I add every c and h file in the library (by right clicking on project, add files) and still get tons of strange errors. And it's not only this particular library, I can't seem to be able to include any other library made for Arduino. So my question is how arduino libraries in generall are used with CodeBlocks. Whats the correct way to include them. It seems there aren't many tutorials on the subject.
« Last Edit: March 17, 2022, 10:55:21 am by zhezhoo »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7298
    • My Best Post
Re: How to link libraries
« Reply #4 on: March 17, 2022, 11:13:23 am »
You need an C++ compiler to compile C++ files; that might be your problem. Please post a build log so it can be confirmed.

https://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28general%29#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org