APM library in command line utility

Discussion in 'Mac Programming' started by jerrywickey, Jul 29, 2010.

  1. jerrywickey macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #1
    I'm working on a personal project that requires math to at least 200 significant digits. Believe it or not there is a huge difference between:

    0.999999999999999999999^2e20 = 0.81873075307...
    and
    0.99999999999999999999^2e20 = 0.13533528323...

    But double precision only recognizes
    0.9999999999999999

    I downloaded an arbitrary precision math package, MAPM. It has all the source code and header files, but dropping the load into the source folder and using #include <MAPM.H> in my application doesn't work.

    I am sure it is just something I am missing. I don't know how to get Xcode to recognize the library for compiling.

    Could someone explain how to do that.

    Also, I am not married to MAPM if someone knows a simpler math package that is already installed in Xcode, perhaps.

    Jerry
     
  2. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #2
    It seems straight forward to build and use. If you're the slightest bit familiar with the Terminal you should be able to get something thats usable in short order.

    For example if the unarchived folder is located on the Desktop the following commands issued in the Terminal will compile and build the static library 'libmapm.a' that you link to in your own projects.

    cd ~/Desktop/mapm_4.9.5a
    make -f makefile.osx

    Once done you should find the file 'libmapm.a' in the 'mapm_4.9.5a' folder. This is the compiled library you need to link your application agaist. You'll also find the header file 'm_apm.h' you'd need to include in your code that makes use of the library.

    A very easy thing to do would be copy both 'libmapm.a' and ''m_apm.h'' into your projects file tree. And them add them to your Xcode project file for use.
     
  3. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #3
    Thank you so much for your help. Glad to see you are familiar with the library.

    The makefile.osx is actually one more directory down.

    85:downloads jerrywickey$ cd mapm495a
    85:mapm495a jerrywickey$ cd unix_osx
    85:unix_osx jerrywickey$ make -f makefile.osx

    make: *** No rule to make target `mapmhasn.c', needed by `mapmhasn.o'. Stop.

    Does this mean that makefile.osx is missing something?

    Jerry
     
  4. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #4
    I assume when you installed Xcode that the check-box "Unix Development" was checked?

    Your distribution seems to be different then the one I downloaded as I don't see a directory named 'unix_osx'.
     
  5. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #5
    Post the output of:
    Code:
    make -n -f makefile.osx
    
    What OS version?

    What Xcode version? I assume you installed Xcode for its compilers and tools. Otherwise what tools versions?
    Code:
    gcc --version  
    make --version
     
  6. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #6
    The terminal command and its results:


    Code:
    85:unix_osx jerrywickey$ make -f makefile.osx
    
    make: *** No rule to make target `mapmhasn.c', needed by `mapmhasn.o'. Stop.
    


    Mac OS 10.5.8
    Xcode 3.1.3

    Component versions
    Xcode IDE: 1191.0
    Xcode Core: 1192.0
    ToolSupport: 1186.0

    My download of MAPM includes a unix_OSX subdirectory. There is no file makefile.osx in the main directory. But there is such a file in the unix_osx directory.

    I don't recall a check box labeled "Unix Development" but I installed Xcode a year ago.

    The file is makefile.osx and a file makefile.unx in the unix_osx directory. I presume one is for unix and one for mac.

    Jerry
     
  7. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #7
    Well you could try the one I pointed at above or provide me a link to what you're trying to use.
     
  8. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #8
    I downloaded MAPM today from the link:

    Download the DOS / Win NT/9x distribution : mapm495a.zip


    at the bottom of the page:

    http://www.tc.umn.edu/~ringx004/mapm-main.html



    But if you can point me to a download that worked for you, that's great!

    Jerry
     
  9. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #9
    Click on the word "downloaded" in my post above.

    Edit: I see we both got them at the same URL. The difference is I downloaded the UNIX distribution and you didn't.
     
  10. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #10
    The downloaded from your link gets me past make -f

    The file was make_osx.old

    Code:
    Make -f make_osx.old  
    
    completed.

    I dropped the files libmapm.a and m_apm.h into the source sub directory of my project and clicked "add" when asked and

    Code:
    #include <m_apm.h>
    But on build I still get "No such file or directory"

    I'm close. What stupid thing am I still doing wrong.
     
  11. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #11
    Keep in mind that the way you're using the static library is kind of ad-hock and not really the UNIX way.

    Try changing that to -

    #include "m_apm.h"
     
  12. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #12
    I don't intend to use unix. The only reason unix came up is because of the folder's name unix_osx.

    I used the terminal command

    Code:
    Make -f make_osx.old
    
    So unix shouldn't be an issue.

    I tried all caps, all lc. I eyeballed the file name directly out of Xcode's groups and files. Some how the compiler isn't seeing the file.

    Could you rehearse the procedure for linking a file to a project.

    Jerry
     
  13. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #13
    You're using Mac OS X. Mac OS X is Unix. Just sayin'.


    You also might want to review the meaning of <>'s in #includes like this:
    Code:
    #include <m_apm.h>
    
    The normal interpretation is "search system locations, excluding user locations", where one like this:
    Code:
    #include "m_apm.h"
    
    means "search user locations". These interpretations can be changed with compiler options or env-vars.
     
  14. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #14
    Yup! thats it!

    "" instead of <>

    There are so many idiosyncrasies in modern compilers. (and they are just that: idiotic ) They are intended to make things more convenient, but at the same time everyone claims the more general the better. like i++ instead of i=i+1 even the use of an = sign instead of the more general set_g(g+1)

    Ahhhh for the days of assembly language. I'm too old for this stuff.

    Thanks very much.

    Jerry
     
  15. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #15
    It was lloyddean who first pointed it out, a few posts up.

    I don't know what "idiosyncrasies in modern compilers" you mean. This is classic C behavior, from the very first K&R book, and C is hardly a modern language. Unless "modern" means "after structured programming". Every language seems idiosyncratic (or idiotic) when unfamiliar.
     
  16. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #16
    I don't know how old or young you are. C may be an oooooold language to you, but when I started, I had to hand compile 6502 mnemonic instructions to machine code. There were 176 instructions. This included all the flavors of load accumulator and bit wise shifts and rolls.

    I'm old.

    Familiarity isn't a test for idiosyncratic. Familiarity just makes it seem like it makes sense, whether it does or not. I am not uneducated in definitive disambiguation. I bet most of you young'ns didn't even know that programming in any language is simply a special case of definitive disambiguation.

    Thank you for the help and check out my iPhone app. DNA Song

    Jerry
     
  17. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #17
    Do you recall your Intel 4004 assembler?

    Wasn't that a real pain flipping those levers specifying address and data values into less that 1024 byte of memory! Just so you could boot strap your tape reader so you could in turn bootstrap your ASR-33 teletype terminal!
     
  18. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #18
    I don't know a 4004 but I do remember breaking my pencil point pushing micro switches to set page addresses.

    Jerry
     
  19. lloyddean macrumors 6502a

    Joined:
    May 10, 2009
    Location:
    Des Moines, WA
    #19
    Now there's a real no-no! Graphite particles falling to the circuit board below can do some real damage! The tip a Jewelers screw driver would've been a better choice.
     
  20. jerrywickey thread starter macrumors member

    Joined:
    Apr 16, 2009
    Location:
    Key West
    #20
    Yeah, well... wait till I tell you about holding my coffee in one hand, a big fat, sloppy pencil in the other and leaning over squinting at the board to find which switch direction is mark and set, because I am too lazy to go to the next room to get my glasses.

    What could possibly go wrong?

    Jerry
     

Share This Page