title: MAC OSX-Write Xcode .Dylib to use in JNA (Java Native Access ) -JAVA
body: <p>Till now i was using dll file with JNA in windows successfully. I had created dll in VC++ successfully which then loaded in Java using JNA. 
  But now i have requirement where i need to provide same software in Mac Os also.</p>
  
  <p>as I have not worked with mac os and Xcode i don't know how to create .dylib.</p>
  
  <p>Here is what i have tried so far using Google and other resources.</p>
  
  <p>1)Opened Xcode, selected "create a new Xcode project"</p>
  
  <p>2)Selected Framework &amp; library , and clicked C/C++ Library </p>
  
  <p>3)I gave Project Name as SimpleDylib and choose Type as Dynamic and pressed next.</p>
  
  <p>4)then i added new file, a C++ file to this project and gave name as SimpleDylib.cpp</p>
  
  <p>5) I wrote a simple function</p>
  
  <p><code>int addNumber(int a,int b)
      { 
      return a+b;
      }</code></p>
  
  <p>From here i don't know  how to export this function. Like in windows VC++ i use .def file to export the function successfully. And in java using jna i am able to use this dll and function inside dll successfully.</p>
  
  <p>in Xcode i tried to use </p>
  
  <p><code>#define EXPORT _attribute__((visibility("default")))
        EXPORT 
      int addNumber(int a,int b)
      { 
      return a+b;
      }
  </code></p>
  
  <p>but still i was not able to use this dylib in Java and i get error as</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.UnsatisfiedLinkeError: Error lloking up function 'addNumber' : dlsym(0x7fb930d49930,addNumber) : symbol not found</p>
  </blockquote>
  
  <p><strong>So how do i export function from dylib? Did my above steps are correct so far? What is the way to create .dylib which can be loaded and use in JNA-JAVA.</strong></p>