issues creating a library in prop c

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.


831 x 648 - 71K

Comments

  • 23 Comments sorted by Date Added Votes
  • Did you click on the key in the lower left corner?

    Did you do Project add simple library?

    Mike

  • Yes I did that. I am going to start over again. This is very frustrating. I have not been able to create a library that works. Even following the actual tutorial by cutting and pasting does not work.
  • zip up your library and attach it here an I will take a look at.

    Mike

  • I have been writing c code for a year but never have been able to get the library stuff to work.
    thanks for taking a look at this.
  • Worked for me...
    Project Directory: /Users/me/Documents/PropCCode/
    
    SimpleIDE Version 1.1.1
    /Users/me/Documents/SimpleIDE/Learn/Simple Libraries/
    /Users/me/Documents/SimpleIDE/ Updated on: 2018-02-07
    
    propeller-elf-gcc -v GCC 4.6.1 (propellergcc-alpha_v1_9_0_)
    propeller-elf-gcc -I . -L . -I ./../SimpleIDE/Learn/Simple Libraries/libgpstest -L ./../SimpleIDE/Learn/Simple Libraries/libgpstest/lmm/ -I ./../SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L ./../SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/lmm/ -I ./../SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L ./../SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/lmm/ -I /Users/me/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L /Users/me/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/lmm/ -I /Users/me/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L /Users/me/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/lmm/ -o lmm/useGPS.elf -Os -mlmm -m32bit-doubles -fno-exceptions -std=c99 useGPS.c -lm -lgpstest -lsimpletools -lfdserial -lsimpletext -lsimplei2c -lm -lgpstest -lsimpletools -lfdserial -lsimpletext -lm -lgpstest -lsimpletools -lfdserial -lm -lgpstest -lsimpletools -lm -lgpstest -lm
    propeller-load -s lmm/useGPS.elf
    propeller-elf-objdump -h lmm/useGPS.elf
    Done. Build Succeeded!
    

    I just needed to add each of the simple libraries, once again to get a good compile.

    sample.jpg


    dgately
    1666 x 1008 - 292K
    Livermore, CA (50 miles SE of San Francisco)
  • Ok, I cleaned up your library and put it into working order.

    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
  • iseriesiseries Posts: 157
    edited April 15 Vote Up0Vote Down
    Ops almost forgot to show the program that uses the library.
    #include "mygps.h"
    #include "simpletools.h"
    
    char *rmc;
    char *gga;
    
    int main()
    {
      start_gps(0, 1, 0, 9600);
    
      rmc = getRMC();
      gga = getGGA();
    
      while(1)
      {
        if (strlen(rmc) > 0)
          print(rmc);
        if (strlen(gga) > 0)
          print(gga);
        pause(500);
      }  
    }
    

    Also I did not test the code to see if actually works either. I rarely code correctly.

    Mike
  • I've made a few libraries that have worked. But I've also made some mistakes when creating them. Can you post a copy of the full error message you get when you try to run the test program?

    Thanks
    Tom
  • I have not worked on this for a week I will post today
    Thanks
  • The error message says no such library

    828 x 640 - 76K
  • Actually the compiler can't find the header file testgps.h. It's not even getting to the linker phase. Where is the file testgps.h located? I've never created a library myself under SimpleIDE, but I believe the header file and library should be located in a sub-directory named libtestgps under the "Simple Library" directory tree.
  • I first used the tutorial exactly as it was described and can't get the tutorial's library to work.
    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
  • From your first post the directory path of your project is C:\Users\mm\Desktop\april gps library test 2018\. Can you post the full directory path for your library?
  • You need to click on the Show Project Manager tab so that you can see what's included in your project

    See attached screen shot.

    Mike
    1220 x 760 - 43K
  • twm47099twm47099 Posts: 662
    edited April 22 Vote Up0Vote Down
    The primary error I found was the naming of the ".h" file. It should be the same as the test harness but without the "lib".
    //#include "testgps.h"       // ******** this needs to be gpstest.h *******
    
    I've made that mistake before on libraries I built. The tutorial is not very clear on that.

    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

    C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/
    C:/Users/tandj/Documents/SimpleIDE/ Updated on: 2018-04-16
    
    propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2408)
    propeller-elf-gcc.exe -I . -L . -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 -c mygps.c -o cmm/mygps.o
    propeller-elf-gcc.exe -I . -L . -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Utility/libsimpletools/cmm/ -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libsimpletext/cmm/ -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/Protocol/libsimplei2c/cmm/ -I C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial -L C:/Users/tandj/Documents/SimpleIDE/Learn/Simple Libraries/TextDevices/libfdserial/cmm/ -o cmm/libgpstest.elf -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 cmm/mygps.o libgpstest.c -lm -lsimpletools -lsimpletext -lsimplei2c -lfdserial -lm -lsimpletools -lsimpletext -lsimplei2c -lm -lsimpletools -lsimpletext -lm -lsimpletools -lm
    C:\Users\tandj\AppData\Local\Temp\ccwvc9n9.o: In function `_Baud_rate':
    (.data+0x8): multiple definition of `_Baud_rate'
    cmm/mygps.o:(.data+0x10): first defined here
    C:\Users\tandj\AppData\Local\Temp\ccwvc9n9.o: In function `_mode_':
    (.bss+0x0): multiple definition of `_mode_'
    cmm/mygps.o:(.bss+0x0): first defined here
    C:\Users\tandj\AppData\Local\Temp\ccwvc9n9.o: In function `_tx_pin':
    (.data+0xc): multiple definition of `_tx_pin'
    cmm/mygps.o:(.data+0x14): first defined here
    C:\Users\tandj\AppData\Local\Temp\ccwvc9n9.o: In function `_rx_pin':
    (.bss+0x4): multiple definition of `_rx_pin'
    cmm/mygps.o:(.bss+0x4): first defined here
    collect2: ld returned 1 exit status
    Done. Build Failed!
    
  • twm47099 wrote: »
    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.

    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:
    int rx_pin = 0;
    int tx_pin = 27;
    int mode_ = 0;
    int Baud_rate = 9600;
    

    In the .h file:
    extern int rx_pin;
    extern int tx_pin;
    extern int mode_;
    extern int Baud_rate;
    

    Note that the extern declarations doesn't have the value assigned.
    VT-100 Terminal and Graphics Card for the RC2014 Z80 Computer
  • Thanks for the information.
    Tom
  • hey guys thanks for your help I finally got it to work
  • I had a discussion with Dave at Parallax about the tutorial not being very clear on some things like having to name the library lib... and other minor information that makes this confusing.

    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???
  • pilot0315 wrote: »
    I had a discussion with Dave at Parallax about the tutorial not being very clear on some things like having to name the library lib... and other minor information that makes this confusing.

    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

  • You still have some problems with your library.

    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
  • Got it thanks
Sign In or Register to comment.