Studio 6 external libraries??

Go To Last Post
30 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How do I include external libraries?

I tried using the full path but I get undefined references.

Thanks,
Ralph

[/img]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just doing the #includes will not pull in the libraries as such.

You need to add a reference to the library to the link stage of the build:

Project, Properties.
Then the Toolchain tab.
Then, AVR/GNU Linker.

Add the library name in the top listbox. If the library is in a non-standard folder you need to add the folder path in the bottom list box.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You need to add a reference to the library to the link stage of the build:
Assuming that these are indeed actual libraries. I suspect, however, that they are simply code modules that need to be compiled. For that you need to add the .c files to your project in order for them to be built.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Johan, I think I asked this same question two years ago.

The actual path is C:\Nerdkits\Code\libnerdkits.

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The error says cannot find
-lc:\Nerdekits\Code\libnerdkits

I do not not know why the -l is there.

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Studio adds the -l for you.

However you may want to explore the use of -L to set the lib search path separately. Then just -lnerdkits for the actual link.

BTW don't the suppliers of "Nerdkits" have up to date instructions of how to use AS6 then?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ralphxyz wrote:
The error says cannot find
-lc:\Nerdekits\Code\libnerdkits

I do not not know why the -l is there.


So, is the library actually in c:\Nerdekits\Code\ ?

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also the name is "nerdkits" not "libnerdkits". When you use -l the linker prefixes "lib" and suffixes ".a" so if you specify "libnerdkits" it will look for a file "liblibnerdkits.a" which won't be right either.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The files are in the C:\Nerdkits\Code\libnerdkits\ folder.

Do I have to specify each file? I only used the path to the folder when we went through this two years ago. That was in Studio 4.

Quote:
Assuming that these are indeed actual libraries.

Koshchi the first screen shot shows my includes for .h files which I am referring to as the libraries I am trying to "include".

Maybe I should change my question to:
How does one include external files in their source file?

I have not used Studio very much and thought I'd give Studio 6 a try.

Quote:
BTW don't the suppliers of "Nerdkits" have up to date instructions of how to use AS6 then?

No, they exclusively use the command line, that is why I have not been using Studio.

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What files are in that C:\Nerdkits\Code\libnerdkits\ directory? Are they libXXXXX.a and XXXX.h files or are they XXXX.c and XXXX.h files? In other words are you talking about real binary libraries or is it this modern hijack of the word "library" when it's really just a few additional source files?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
really just a few additional source files

They are just .c and .h files.

Which would have been obvious if the screen shot had been readable.

So my revised question is:

Quote:
Maybe I should change my question to:
How does one include external files in their source file

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to add the .c source files to your project. Right click on the project in Project Explorer in AS6, and select Add existing.. Next, browse to the file, and either click Add (in which case a copy of the file will be added to your project folder, and added to the project build system), or uses the pull-down part of the Add button to select Add as link (in which case the file will be used in its current place). Repeat for all source files (.c) you want to add to the project.

Since we started off with a screen shot of a few #include directives, I'll pass this side note: The #include directive very little in common with the import/using stuff in high level languages like Java and C#. Doing an #include in C (or C++) just tells the compilers pre-processor to replace a piece of the source code with the contents of another file (the included file). It does not point out any source file. Indeed, there is no technical coupling between header files and source files. It is often by convention of name, but need not at all be. And it is up to you, the programmer to make the appropriate #includes and compiling the corresponding .c source files so that the linker gets all the .o files it needs.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Johan, what is the Project Explorer?

There is nothing in help about a Project Explorer.

I can see a icon on the tool bar that is labeled "Add" (Ctrl+Shift+A) but that is grayed out and not accessible.

Sorry I am just trying to learn Studio 6, as I am not familiar at all with it.

And yes this is just about the #include directive.

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, should be "Solution Explorer".

In Solution Explorer, right-click the project (normally the one and only second to top node) and select "Add..", "Existing Item...".

(Hope I got it right this time :oops: )

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now where do I right click??

I do not see the project you are speaking of.

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The project node is the second from the top, i.e. the yellow speedcontrol folder.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Johan, got it finally.

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry but once I add the files how do I include them?

Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Sorry but once I add the files how do I include them?

If you are talking about #include of .c files: You just don't.

If a .c file is in the tree in the Solution explorer it will be compiled into an .o file.

The linker will combine the separate .o files into one .elf, which will then be converted to a hex file.

The #include is used to get the contents of a .h file into the contents of a .c file at compilation.

These are two technically totally separate mechanisms, although they are often used "in concert" to form a system for separate compilation while upholding interfaces between the separately compiled "modules".

I tried to hint at this above, but it obviously didn't hit. Can we assume that this is your first encounter with a C tool chain (honest question, so we know on which level to formulate the answers).

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ChaunceyGardiner wrote:
Ralphxyz wrote:
The error says cannot find
-lc:\Nerdekits\Code\libnerdkits

I do not not know why the -l is there.


So, is the library actually in c:\Nerdekits\Code\ ?

Ralphxyz wrote:
The files are in the C:\Nerdkits\Code\libnerdkits\ folder.
I was pointing to the obvious, and you seem to still be missing it.

The linker is looking for c:\Nerdekits\... which doesn't exist. The image you posted shows this typo in the library search path, so that is the most likely cause of the linker message.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sid! The "link lib path track" was a phoney. The OP has made it clear that it is not a real library (as in "archive of object files") he has, but "only" a collection of .c and .h files. While the erroneous link path probably generated the error message we are past that, and are now trying to get the OP to add the .c files to the project so that they actually will get built. Notice that in the very first screen dump the OP has several "undefined reference to XXX" errors, so typical when eg a lcd.h file is #included into e.g. main.c, but the lcd.c file not added to the source files to be compiled.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You would get the same messages if a library was missing, but if there is no library you will obvioualy either have to build one or include the source files in your project.

I would prefer to add it as a library project to my solution, then make my executable project depend on that project. It will still be rebuilt whenever you rebuild the solution, this is just a way to organize things to make it easier to keep track.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You would get the same messages if a library was missing

Be that as it may, but the OP has made it clear that he has a bunch of .c and .h files.

Quote:
I would prefer to add it as a library project to my solution

I might to, but I do not think that going into a multi-project solution (with two different types of projects involved to boot) will make things clearer for the OP right now. Read through the thread again to see how the concept of separate compilation is really weak, how repeatedly there seems to be a misconception that #include does more than it actually does etc etc.

I believe that the first thing to understand is how a compiling linking tool chain basically works. Only after that should things like building your own library be dealt with. All IMO.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
You would get the same messages if a library was missing

Be that as it may, but the OP has made it clear that he has a bunch of .c and .h files.

Quote:
I would prefer to add it as a library project to my solution

I might too, but I do not think that going into a multi-project solution (with two different types of projects involved to boot) will make things clearer for the OP right now. Read through the thread again to see how the concept of separate compilation is really weak, how repeatedly there seems to be a misconception that #include does more than it actually does etc etc.

I believe that the first thing to understand is how a compiling linking tool chain basically works. Only after that should things like building your own library be dealt with. All IMO.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I agree, but in that case it would be a better idea to start with something simpler.

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Chauncey, good eye, but that was a typo on my part!!

If you could actually see the screen shots you'll see the correct spelling.

Thanks for the reply,
Ralph

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If possible, always avoid typing in stuff by hand that you can copy+paste. Typos creates confusion and frustration, and people (like Sid this time) spend time thinking about a problem that isn't really there. Effectively you have wasted his time.

It is quite possible to mark the error message in studio, and paste it in a post here.

No typos. No frustration. Happy helpers. Happy you.

-----

So how are we doing with the actual problem of adding the .c files to the project in Atmel Studio?

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Imagination seems to be a bigger interference than spelling here. If you look closely at OP's picture above, you may notice this:

Attachment(s): 

Sid

Life... is a state of mind

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps. But it is still not something that is the reason for the OPs current problems.

We led him astray talking about how to add a "proper" library to a project. Unfortunate, IMO. This is not what the OP has/needs, at least right now. Arguing over a moot case will not make things clearer for him.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Johan,

I'm just trying to bring clarity to what has already been said. Like I said before, I agree with your description of what the cause of the problem is.

Sid

Life... is a state of mind