Mac APM library in command line utility

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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
 

lloyddean

macrumors 65816
May 10, 2009
1,002
16
Des Moines, WA
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.
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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
 

lloyddean

macrumors 65816
May 10, 2009
1,002
16
Des Moines, WA
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'.
 

chown33

Moderator
Staff member
Aug 9, 2009
8,732
5,064
vertical
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
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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
 

lloyddean

macrumors 65816
May 10, 2009
1,002
16
Des Moines, WA
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.
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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.
 

lloyddean

macrumors 65816
May 10, 2009
1,002
16
Des Moines, WA
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"
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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
 

chown33

Moderator
Staff member
Aug 9, 2009
8,732
5,064
vertical
I don't intend to use unix. ...
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.
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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
 

chown33

Moderator
Staff member
Aug 9, 2009
8,732
5,064
vertical
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
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.
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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
 

lloyddean

macrumors 65816
May 10, 2009
1,002
16
Des Moines, WA
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!
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
I don't know a 4004 but I do remember breaking my pencil point pushing micro switches to set page addresses.

Jerry
 

lloyddean

macrumors 65816
May 10, 2009
1,002
16
Des Moines, WA
I don't know a 4004 but I do remember breaking my pencil point pushing micro switches to set page addresses.

Jerry
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.
 

jerrywickey

macrumors member
Original poster
Apr 16, 2009
81
0
Key West
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
 

Similar threads

  • jasnw
2
Replies
2
Views
1K
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.