Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined errors while compiling fortran code #28

Closed
vineetpant opened this issue Dec 15, 2014 · 2 comments
Closed

undefined errors while compiling fortran code #28

vineetpant opened this issue Dec 15, 2014 · 2 comments

Comments

@vineetpant
Copy link

Hello ,
I am trying to cross compile simple "hello world" printing fortran code with the following command -

o64-g++ test.f -O3 -o test

and i am getting following errors, i think there should be some library which is missing from being referenced.


"gfortran_set_args", referenced from:
_main in ccunQ19M.o
"__gfortran_set_options", referenced from:
_main in ccunQ19M.o
"__gfortran_st_write", referenced from:
_MAIN
in ccunQ19M.o
"gfortran_st_write_done", referenced from:
_MAIN
in ccunQ19M.o
"gfortran_transfer_character_write", referenced from:
_MAIN
in ccunQ19M.o
ld: symbol(s) not found for architecture x86_64


Thanks & Regards,
Vineet Pant

@tpoechtrager
Copy link
Owner

You need to use x86_64-apple-darwin14-gfortran, not o64-g++ or x86_64-apple-darwin14-g++.

$ cat test.f
Program Hello
  Print *, "Hello World!"
End Program Hello

The dynamic way:

$ x86_64-apple-darwin14-gfortran -ffree-form test.f -o test

$ x86_64-apple-darwin14-otool -L test
test:
        /data/development/osxcross/target/bin/../x86_64-apple-darwin14/lib/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
        /data/development/osxcross/target/bin/../x86_64-apple-darwin14/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
        /data/development/osxcross/target/bin/../x86_64-apple-darwin14/lib/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

$ dyld test
 Hello World!

The static way:

$ x86_64-apple-darwin14-gfortran -static-libgcc -static-libgfortran -ffree-form test.f -o test

Still links quadmath dynamically:

$ x86_64-apple-darwin14-otool -L test
test:
        /data/development/osxcross/target/bin/../x86_64-apple-darwin14/lib/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

If you want to link quadmath static too, run (in osxcross/target):

$ cp -r x86_64-apple-darwin14 backup
$ find x86_64-apple-darwin14 -name "libquadmath*dylib" -exec rm {} \;

Use the same flags again:

$ x86_64-apple-darwin14-gfortran -static-libgcc -static-libgfortran -ffree-form test.f -o test
$ x86_64-apple-darwin14-otool -L test
test:
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

@vineetpant
Copy link
Author

Hi ,
It is working fine , i built it with statically.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants