trouble making a library

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Imsmooth
 
Posts: 15
Joined: Tue Feb 25, 2014 8:16 pm

trouble making a library

Post by Imsmooth »

I copied the adafruit_ads1015 .h and .cpp routines into a test file and they compile fine with Arduino 1.0.5.

I then copied these files into a subdirectory Adafruit_ADS1x15 and placed this subdirectory into my \libraries subdirectory.

When I compile I get compiler errors like "multiple definitions" of routines that are only defined once. Any suggestions what I am not doing correctly? The code has not changed.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: trouble making a library

Post by adafruit_support_bill »

I then copied these files into a subdirectory Adafruit_ADS1x15 and placed this subdirectory into my \libraries subdirectory.
Where did you copy them from? If there is more than one copy anywhere in the libraries subdirectory, you will get multiple definitions.

The Arduino IDE works a little differently than a typical build environment. It scans all the libraries at startup.

Imsmooth
 
Posts: 15
Joined: Tue Feb 25, 2014 8:16 pm

Re: trouble making a library

Post by Imsmooth »

There is the one copy in the \libraries and the copy it creates in the working subdirectory.

I've tried adding the #ifndef within the header file but this did not work either

The adafruit_ads1015.h file is getting included twice. Your code includes it in your .cpp file and I have to include it in my testfile.ino
What is the workaround and why does it work when I just have it in the working directory and *not* the library?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: trouble making a library

Post by adafruit_support_bill »

What exactly are you trying to accomplish? You don't need to make a copy of the library to use it. Just install it as described here: http://learn.adafruit.com/adafruit-all- ... nstall-use
Then include it in your code like the example sketches.

Imsmooth
 
Posts: 15
Joined: Tue Feb 25, 2014 8:16 pm

Re: trouble making a library

Post by Imsmooth »

I wanted to put the .h and .cpp into my arduino library for future use. I wanted to carve it out of the program into a separate area

EDIT: I see when looking at the library subdirectory that I am creating that there is no Keywords file. Could this be the issue as to why it does not work when I try to use a library?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: trouble making a library

Post by adafruit_support_bill »

I wanted to put the .h and .cpp into my arduino library for future use. I wanted to carve it out of the program into a separate area
I still don't understand what you are trying to do. If the library is properly installed, you can use it from as many sketches as you want.
http://learn.adafruit.com/adafruit-all- ... nstall-use

Imsmooth
 
Posts: 15
Joined: Tue Feb 25, 2014 8:16 pm

Re: trouble making a library

Post by Imsmooth »

problem solved.
I had to rename the library to remove the "_" which is mentioned in the link you sent. It is such I subtle point I missed it.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”