# Makefile for creating shared object using common.mk 'wrong architecture' errors when loading

**URL:** <https://forums.developer.nvidia.com/t/makefile-for-creating-shared-object-using-common-mk-wrong-architecture-errors-when-loading/16870>\
**Category:** CUDA Programming and Performance\
**Created:** [May 30, 2010, 7:02pm UTC](https://forums.developer.nvidia.com/t/makefile-for-creating-shared-object-using-common-mk-wrong-architecture-errors-when-loading/16870 "2010-05-30T19:02:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Marcel](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@\_Marcel](https://forums.developer.nvidia.com/u/_Marcel)\
**Post date:** [May 30, 2010, 7:02pm UTC](https://forums.developer.nvidia.com/t/makefile-for-creating-shared-object-using-common-mk-wrong-architecture-errors-when-loading/16870/1 "2010-05-30T19:02:39Z")

</div>

Hello,

I’m trying to compile my CUDA project on OSX but encountering some errors which I don’t know how to solve. I compile my project on Linux with just a few extra arguments to nvcc:

```auto
nvcc -shared -Xcompiler "-fPIC" -c in.cu -o out.o -I<includes..>

```

The final linking, on Linux, is done with gcc as following:

```auto
gcc -std=gnu99 -shared -o sharedlib.so in.o -lcuda -lcudart -lcublas

```

So I’m trying to create a Makefile for my project on OSX, preferably using the common.mk file (I don’t have experience making Makefiles using these rules btw).

So I added the following line to my Makefile:

```auto
COMMONFLAGS += -shared -Xcompiler "-fPIC"

```

but I’m unsure how I tell to create a shared object for the linking phase, any ideas?

Currently, if I manually link the objects files into a shared object, I get the following error when loading the file:

```auto
unable to load shared library 'rgputools.so':

  dlopen(rgputools.so, 6): no suitable image found. Did find:

	rgputools.so: mach-o, but wrong architecture

```

If someone can advice what to do, or what other information is needed, I would be very grateful!

System: Apple MacBook Pro 13 inch, Nvidia 320M

CUDA version: 3.0, examples are all working fine.
