issues creating a library in prop c
pilot0315
Posts: 910
in Propeller 1
I have followed the tutorial countless times. Never been able to get it to work. Tried again to create one, and it appears to work until I do the test phase with a new program and call the library and get this error:
I followed all the steps line by line. It only works with the first program.
I followed all the steps line by line. It only works with the first program.
Comments
Did you do Project add simple library?
Mike
Mike
thanks for taking a look at this.
I just needed to add each of the simple libraries, once again to get a good compile.
dgately
The nice think about libraries is you get to define a test program to test your library.
Once that is working build a new program and include it by selecting the add simple library button.
I think you were using the test program "libmygps.c" as the program to run but this is just a test program that never gets put into production. It is there just to test the library and then is not used anywhere.
You also don't need to include any other libraries as they are built into the compiled libraries.
I put my libraries in the learn/Simple Libraries/Custom folder so I know these are the ones I built.
Look it over and let me know. I made a lot of changes so let me know.
Mike
Also I did not test the code to see if actually works either. I rarely code correctly.
Mike
Thanks
Tom
Thanks
I then decided to attempt the same with my code.
Can't get it to work using the turorial's awsome lib names.
I have and am as we speak attempting for the third time today to make a library. The library files are kept in a folder in the SimpleLibraries file
See attached screen shot.
Mike
The problem I had was taking the variable declarations out of the .c files and putting them into the ".h" file. I kept getting the error listing below. The solution was taking the variable declarations out of the ".h" file and putting them into the "mygps.c" functions file.
Then I was able to build the library and test it using the "no library" example in the above post.
I've attached a zip of the library. Hope this helps.
I'd like any of the experienced C programmers to help me understand why I had problems with declaring variables in the .h file.
Tom
The variables must be declared in the .c file that's correct. To see the variables from other source files, you need to declare them as extern either in an included .h file or in the source itself.
In the .c file:
In the .h file:
Note that the extern declarations doesn't have the value assigned.
Tom
I worked on this off and on for a while and I think I finally got it.
Now to add more libraries what is the procedure?
Is it the case of just adding more .c and adding it to the .h???
Not sure what you mean.
If you want to add more functions to the library, you add the functions to "mygps.c" and put the function prototypes in "gpstest.h"
If you want to add more c files (for example if there are groups of functions that are used together, but that aren't used that often), open "libgpstest.c" in SimpleIDE, go to project, add new tab, and give it a name.c, type in the functions, add their prototypes to the "gpstest.h" file and rebuild the library. The tutorial shows how to do that.
Tom
The Library folder should not be a part of your project.
There are no definitions in the .h file for your functions that your are making in your library.
Mike