I am brand new to this forum, and have just begun to learn C. The book I am going through wants me to compile the code that was written. I have a file "cards.c", I am on a Mac, have Xcode installed, downloaded gcc from Apple and installed it.
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
Target: x86_64-apple-darwin14.4.0
Thread model: posix
When I type:
gcc cards.c -o cards
I get:
clang: error: no such file or directory: 'cards.c'
clang: error: no input files
I have tried going to Xcode downloads to install Xcode's Command Line Tools, it doesn't show up there, maybe I have a newer version?
I cannot figure out how to compile this, any ideas on what I am doing wrong?
Does the cards.c file need to be in a specific folder somewhere?
Related
I am running gcc version 9.4 on MacOS Monterey. I am compiling a simple program with asan enabled. Whenever I do compile, I compile successfully, but I get the following warnings:
ld: warning: dylib (/usr/local/Cellar/gcc#9/9.4.0/lib/gcc/9/libasan.dylib) was built for newer macOS version (11.3) than being linked (11.2)
ld: warning: dylib (/usr/local/Cellar/gcc#9/9.4.0/lib/gcc/9/libubsan.dylib) was built for newer macOS version (11.3) than being linked (11.2)
I do not want to upgrade my version of gcc because my remote machine uses gcc 9.4 and I do not have sudo access on that machine to upgrade it.
I have tried using the -L flag along with the following directory:
-L/usr/local/Cellar/gcc#9/9.4.0/lib/gcc/9/, but that also did not get rid of the warning. Is there a way I can fix this warning while also not upgrading my version of gcc?
Edit: gcc was installed via Homebrew
I am on a Debian linux build environment and cannot change this. We build our apps using mingw and would like to use the openssl suite of tools in one of our applications. The linux version contains the includes openssl/md5.h and compiles gcc with the -lcrypto flag and works great.
What do I need to do to build the Windows dll using mingw and include openssl?
My build command looks like this
x86_64-w64-mingw32-gcc -shared -s FILE.c FILE.def -lcrypto -lws2_32 -o OUT.dll
This produces the error fatal error openssl/md5.h no such file or directory.
I have tried to add the -I /path/to/openssl/includes
Then get the ld error cannot find -lcrypto. I have the libssl-dev libraries.
I have the source for openssl and have tried to compile it using mingw as some other articles have suggested. "cannot find -lcrypto -lssl" with OpenSSL on Windows with MinGW
But the build always fails with multiple files missing the include bits/libc-header-start.h. My thinking was if I can get the windows dlls on the linux system maybe that was what mingw needed.
I have tried to install gcc-multilib as suggested in this post "fatal error: bits/libc-header-start.h: No such file or directory" while compiling HTK but that leads to a basket of missing dependencies.
Is it even possible to build a Windows dll including openssl dependencies from a Debian dev environment?
Thanks for any assistance.
I am pretty new to the MacOS environment and I previously had some issue compiling C scripts. I had the following issue:
fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
I tried to re-install xcode-select --install but keep telling me
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
I updated everything and nothing. Apparently it is because I don't have the /usr/includes file. I found a way to compile my software by using
/Library/Developer/CommandLineTools/usr/bin/g++ XXXX.cpp
However, now I am trying to ./compile and make another software but I don't know how to use this gcc interpreter by default. When I try to ./configure I got this error
configure: error: cannot run C compiled programs. If you meant to
cross compile, use '--host'. See 'config.log' for more details
So when I do look into config.log :
configure:3224: checking for gcc
configure:3240: found /usr/local/bin/gcc
configure:3251: result: gcc
configure:3282: checking for C compiler version
configure:3291: gcc --version >&5
gcc (GCC) 4.9.2 20141029 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:3302: $? = 0
configure:3291: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-apple-darwin14.0.0/4.9.2/lto-wrapper
Target: x86_64-apple-darwin14.0.0
Configured with: ../gcc-4.9-20141029/configure --enable-languages=c++,fortran
Thread model: posix
gcc version 4.9.2 20141029 (prerelease) (GCC)
configure:3302: $? = 0
configure:3291: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3302: $? = 1
configure:3291: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3302: $? = 1
configure:3322: checking whether the C compiler works
configure:3344: gcc conftest.c >&5
configure:3348: $? = 0
configure:3396: result: yes
configure:3399: checking for C compiler default output file name
configure:3401: result: a.out
configure:3407: checking for suffix of executables
configure:3414: gcc -o conftest conftest.c >&5
configure:3418: $? = 0
configure:3440: result:
configure:3462: checking whether we are cross compiling
configure:3470: gcc -o conftest conftest.c >&5
conftest.c:15:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
configure:3474: $? = 1
configure:3481: ./conftest
./configure: line 3483: ./conftest: No such file or directory
configure:3485: $? = 127
configure:3492: error: in `/Users/XXXX/phyml':
configure:3494: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
Do you have any ideas of how I can fix it ?
Thanks a lot !
It's really easy to miss the answer from melpomene in the small comments to this question so let me post this here for everyone to see. This error usually means you're missing compiler tools (headers actually) that have been removed from Xcode.
You can find them in /Library/Developer/CommandLineTools/Packages/ since their name might be different depending on your version of macOS in the future.
Assuming you're running macOS Mojave (10.14), you need to run:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
And an macOS-style package installer will start, asking you for your adminstrator password. This is an official Apple package and although it might be weird to install something out of a random directory, you can trust it. You don't have to take my word for it though. Apple buried this change in the Xcode 10 release notes and you can find their explanation here: https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035623
I'll reproduce this here in case this link ever goes away or gets changed:
The Command Line Tools package installs the macOS system headers inside the macOS SDK. Software that compiles with the installed tools will search for headers within the macOS SDK provided by either Xcode at:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
or the Command Line Tools at:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
depending on which is selected using xcode-select.
The command line tools will search the SDK for system headers by default. However, some software may fail to build correctly against the SDK and require macOS headers to be installed in the base system under /usr/include. If you are the maintainer of such software, we encourage you to update your project to work with the SDK or file a bug report for issues that are preventing you from doing so. As a workaround, an extra package is provided which will install the headers to the base system. In a future release, this package will no longer be provided. You can find this package at:
/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
> To make sure that you're using the intended version of the command line tools, run xcode-select -s or xcode select -s /Library/Developer/CommandLineTools after installing.
I've already visited the following answer but my question is different.
Install GNU GCC on mac
Mac OS ships with Clang and somehow /usr/bin/gcc is linked to Clang tool I assume because of this line.
gcc
clang: error: no input files
Any idea on how can I install https://gcc.gnu.org/ standalone on my system?
gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Any idea on how can I install https://gcc.gnu.org/ standalone on my system?
Generally speaking: Don't. That isn't a standard configuration; Clang is the recommended compiler for current macOS systems.
If you have a very good reason, you can use Homebrew to install GCC (brew install gcc). Keep in mind that it cannot be used to build native macOS applications.
Using Xcode command line tools, when attempting to compile a C file that includes stdio.h, the compiler is producing the following error:
/usr/include/stdio.h:71:10: fatal error: 'sys/_types/_va_list.h' file not found
#include <sys/_types/_va_list.h>
The compiler info is
LSK-Macbook-Pro:sys larry$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
How can I this this file back so I can use the compiler?