I am using the gfortran compiler on mac osx mavericks. I have installed Xcode and command line tools. I am trying to compile a simple helloworld program with gfortran to test whether everything works, but unfortunately it doesn't work. The error message seems to suggest that I have no main function, but I don't see the error in the code:
program hello
print *, "Hello World!"
end program hello
But when i try to compile using
gfortran helloworld.f
I get the following error:
Undefined symbols for architecture x86_64:
"start", referenced from:
-u command line option
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
I do not understand what is wrong and I am on the verge of despair. I tried with gfortran 4.8.2 as well as gfortran 4.9.0, I tried reinstalling Xcode and Command Line Tools but nothing seems to work.
I am aware similar questions have been asked, but I was not able to find a solution to my problem. I would be happy even with a sloppy workaround, as long as I can get the compiler to run...
Oh my dear. Found the solution about a minute after staring the bounty. Rather than using the recommended installer from https://gcc.gnu.org/wiki/GFortranBinaries I just installed it with
brew install gcc
The gfortran now compiled without complaining.
Related
I'm programing ADA with GPS. The problem is that when I compile any code with GPS I get this error:
ld: library not found for -lSystem collect2: error: ld returned 1 exit status
I have updated and reinstalled everything (xcode, gcc), reinstalled GPS, and installed comand line tools.
That's what GPS show to me by terminal:
gprbuild -d -P/Users/pedromarti/Desktop/helloWorld/default.gpr /Users/pedromarti/Desktop/helloWorld/src/main.adb Bind [gprbind] main.bexch [Ada] main.ali Link [link] main.adb ld: library not found for -lSystem collect2: error: ld returned 1 exit status gprbuild: link of main.adb failed gprbuild: failed command was: /users/pedromarti/opt/gnat/2019/bin/gcc main.o b__main.o -L/Users/pedromarti/Desktop/helloWorld/obj/ -L/Users/pedromarti/Desktop/helloWorld/obj/ -L/users/pedromarti/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/ /users/pedromarti/opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib/libgnat.a -Wl,-rpath,#executable_path/ -Wl,-rpath,#executable_path/../../..//opt/gnat/2019/lib/gcc/x86_64-apple-darwin17.7.0/8.3.1/adalib -o main [2021-03-18 13:38:56] process exited with status 4, elapsed time: 02.57s
I don't know what more I can do. If anyone knows a solution, you are welcome!
You’re using GNAT Community Edition 2019. I can’t tell which OS release you’re running on, and in this case I don’t think it makes a difference.
The README from the download site says
== Mac OS: Xcode is now needed ==
On Mac OS, GNAT Community 2019 requires Xcode version 10 or above to be
installed. Once you do have Xcode installed, if you still observe an error
of the form:
ld: library not found for -lSystem
then you might have to execute the following:
xcode-select -s /Applications/Xcode.app/Contents/Developer
Xcode is large but free, and takes a while to download from the App Store (go to the Develop tab).
If your building system has a cache system, you need to clear the cache.
For example, if you are using cmake, remember to delete cmake build directory to avoid the cmakecache take it to the wrong link.
I want to try out RInside for Mac OSX. I downloaded RInside from source using Terminal and then went into the /inst/examples/standard and tried to run make, as indicated in the answer to this thread: RInside on Mac OS X
However, the first error I received was fatal error: 'RInside.h' file not found. I manually found this file and put it into the /inst/examples/standard directory and ran make again. I received another fatal error for another .h file so I manually found the requisite file and inserted it into this standard directory. Anyway, after doing that a few more times, all dependencies were taken care of, then I ran make again and received the following very strange error:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I also tried using clang++ -stdlib=libstdc++ in place of g++ (since RInside on Mac OS X says that g++ won't work), but it did not help either (i.e., I received the same architecture errors).
I am stuck here...
UPDATE:
As per Dirk Eddelbuettel's advice, I tried installing XTools (Run Windows X System on OSX), but I received the following error: "Xtools.pkg" is damaged and can't be opened. You should eject the disk image."
I am concerned that running a simple "hello world" script as provided on the RInside webpage (http://dirk.eddelbuettel.com/code/rinside.html) can be this convoluted on the Mac as to demand external installs and miscellaneous configurations. Hence, there must be a more straightforward way to run RInside on the Mac OS X.
I've compiled my SFML program with g++ and that seems to be working fine now (had issues with it previously), however when I try to run the resulting output, I get the following error message:
dyld: lazy symbol binding failed: Symbol not found: __ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE
Referenced from: /Users/fabricecastel/Work/Game_Projects/SFML_tutorials/./a.out
Expected in: /usr/local/lib/libsfml-graphics.2.dylib
dyld: Symbol not found: __ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE
Referenced from: /Users/fabricecastel/Work/Game_Projects/SFML_tutorials/./a.out
Expected in: /usr/local/lib/libsfml-graphics.2.dylib
Trace/BPT trap: 5
I've checked the folder in question and libsfml-graphics.2.dylib isn't missing. Besides that I'm at a total loss as to what the issue is and how I'm supposed to fix it. Seems to me that the RenderWindow symbol isn't included in the dylib but it should be. We're talking SFML 2.1 here, not some obscure amateur project. What's up with that?
The only way I could reproduce these errors is when GCC and Clang version of SFML are mixed. Here are two procedures that create the same errors.
First procedure
install the GCC version
compile your application (successfully)
install the Clang version
run your application
Second procedure
install the Clang version
compile your application (successfully)
install the GCC version
run your application
When you install another runtime, you need to carefully rebuild from scratch your application. That is, remove the final binary as well as any .o files before compiling.
Undefined symbols for architecture x86_64: "_libintl_dgettext", referenced from:
_gpg_strerror in libgpg-error.a(libgpg_error_la-strerror.o)
_gpg_strerror_r in libgpg-error.a(libgpg_error_la-strerror.o)
_gpg_strsource in libgpg-error.a(libgpg_error_la-strsource.o) ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status
As stated by the question , When trying to build my firebreath project which requires libgpgme on MacOSX 10.6 using Xcode I get the error above. My include/search paths are valid since I can run the following command from the console and it works fine.
g++ -o test test.cpp `gpgme-config --libs`
The output form the gpgme-config is -L/opt/local/lib -lgpgme -lassuan -lgpg-error. Not sure what other info is needed , comment and I will updated as needed.
Your problem is that you're building a universal binary for both 32 and 64 bit and the library you're including is not built for 64 bit. You can build i386 only by adding -D CMAKE_OSX_ARCHITECTURES="i386" to your prepmac.sh command-line.
Make sure to delete your build directory before running prepmac.sh with the new argument or it may not take.
See the Prep Scripts page on firebreath.org for more info.
I'm trying to program a graph class using an adjacent list from an example in my C++ text book, and when I compile using this command:
Code:
g++ -o prog program.cpp
...I get the following error:
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
... what in the world does this mean? It may turn out to be an issue with my code, but I feel like it may be deeper than that, because I've gotten this same seemingly inexplicable error for several different projects, many of which were solved in different ways, and unfortunately completely by accident.
I read somewhere that it may have to do with whether I'm using 32 bit or 64 bit libraries, and that the tags -m32 or -m64 may need to be used, but I'm not sure if this applies here. Interestingly enough, when I tried adding the -m64 tag I got the same exact error, but when I tried using the -m32 tag I got the same error, except it said
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
instead.
Mainly I just want to know what in the world the error is saying. I'm used to debugging compile-time errors that give a specific line in the code, etc., but I can't discern anything like that from this. Any ideas?
If it helps, I'm using a late 2008 Macbook with Intel Core 2 Duo, (so 64-bit), and I'm running OS X Lion (10.7.2), which I think is the latest version. Also, I'm using gcc version 4.2.1.
When you compile the file, the compiler invokes the linker which tries to generate an executable. But it cannot because you didn't provide a function named main which is the function that will be executed when your program is launched.
Either you don't want to run the linker because you want to compile several files separately then combine then. In that case, use the -c flag to tell the compiler to skip the link stage.
Or either you want to execute the compiled file. Then you need to implement the function main.