我有一个包含声明的C程序的Makefile
CC?=gcc
Run Code Online (Sandbox Code Playgroud)
把它改成
CC?=g++
Run Code Online (Sandbox Code Playgroud)
不会用g ++编译它.把它改成
CC=g++
Run Code Online (Sandbox Code Playgroud)
是否使用g ++.
所以我想知道?=运算符是做什么的?我的猜测是它查看一个环境变量来决定使用哪个编译器,如果没有设置,那么使用gcc?谁可以解决这个问题?
我尝试在非常简单的项目中运行valgrind 3.13和3.14(在macOs 10.12.6上),但我得到了一个奇怪的错误,我以前从未在linux中获得过.
非常简单的C程序main.c:
int main() {
return (0);
}
Run Code Online (Sandbox Code Playgroud)编译cc:
$> cc main.c
Run Code Online (Sandbox Code Playgroud)运行我的简单程序valgrind:
$> valgrind ./a.out
Run Code Online (Sandbox Code Playgroud)valgrind的输出:
==12768== Memcheck, a memory error detector
==12768== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==12768== Using Valgrind-3.14.0.SVN and LibVEX; rerun with -h for copyright info
==12768== Command: ./a.out
==12768==
==12768== Syscall param msg->desc.port.name points to uninitialised byte(s)
==12768== at 0x10049434A: mach_msg_trap (in /usr/lib/system/libsystem_kernel.dylib)
==12768== by 0x100493796: mach_msg (in /usr/lib/system/libsystem_kernel.dylib)
==12768== by …Run Code Online (Sandbox Code Playgroud)#include <stdio.h>
#include <stdlib.h>
struct NODE {
char* name;
int val;
struct NODE* next;
};
typedef struct NODE Node;
Node *head, *tail;
head = (Node*) malloc( sizeof( Node ) ); //line 21
Run Code Online (Sandbox Code Playgroud)
我编译如下:
cc -g -c -o file.tab.o file.tab.c
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
file.y:21:1 warning: data definition has no type or storage class [enabled by default]
Run Code Online (Sandbox Code Playgroud) 好吧,这里有点无处可去。在我发布了我的 Mac M1 与 Rust Diesel 的链接器问题并没有得到任何结果之前。因此,我启动了一个 Ec2 实例,并尝试在此处运行此包,并得到以下结果:
error: linking with `cc` failed: exit status: 1
...
= note: /usr/bin/ld: cannot find -lpq
Run Code Online (Sandbox Code Playgroud)
我已经安装了以下内容:
sudo yum update -y
sudo yum install git -y
sudo yum groupinstall "Development Tools" -y
sudo yum install cmake -y
sudo yum install postgresql-libs -y
Run Code Online (Sandbox Code Playgroud)
说真的,人们是如何设法让这个箱子运行的?
如果cc配置设置为use -Werror,有没有办法-Werror在使用make时覆盖终端的标志?
我与安装scrapy pip在virtualenv上OS X 10.11.当它正在安装加密时,它说:
building '_openssl' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c build/temp.macosx-10.11-intel-2.7/_openssl.c -o build/temp.macosx-10.11-intel-2.7/build/temp.macosx-10.11-intel-2.7/_openssl.o
build/temp.macosx-10.11-intel-2.7/_openssl.c:423:10: fatal error: 'openssl/e_os2.h' file not found
#include <openssl/e_os2.h>
^
1 error generated.
error: command 'cc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)
Command "/Users/Kris/Workspace/env/scrapy/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/wx/jm7lxhps3n7484zl4gv9s3180000gn/T/pip-build-2rJYgI/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, …Run Code Online (Sandbox Code Playgroud) 有同样的问题和答案。问题是答案似乎是错误的(实际上并不是所问问题的答案)。我可以重新提问吗?问题:
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ whereis gcc
cc: /usr/bin/gcc /usr/lib/gcc /usr/local/bin/gcc /usr/libexec/gcc
$ which gcc
/usr/local/bin/gcc
$ /usr/bin/gcc -v
gcc version 4.1.2
$ /usr/local/bin/gcc -v
gcc version 4.8.4
$ gcc -v
gcc version 4.8.4
$ cmake .
-- The C compiler identification is GNU 4.1.2
...
...
Run Code Online (Sandbox Code Playgroud)
本地 GCC 版本如果是 4.8.4 并且系统的默认版本是“4.1.2”。所有其他工具链都遵守 PATH 环境变量并使用本地(较新的)GCC 版本。除了 CMAKE。设置 CC 不是一个好主意,因为可能还有其他二进制工具也可以使用。在脚本开头设置 CMAKE_PROGRAM_PATH 和 CMAKE_PREFIX_PATH 无助于检测编译器。
有没有办法强制 CMAKE 尊重 PATH 变量?
我的命令有问题
sudo pip install MySQl-python
Run Code Online (Sandbox Code Playgroud)
所有日志:
Downloading/unpacking MySQl-python
Downloading MySQL-python-1.2.5.zip (108kB): 108kB downloaded
Running setup.py (path:/private/tmp/pip_build_root/MySQl-python/setup.py) egg_info for package MySQl-python
Installing collected packages: MySQl-python
Running setup.py install for MySQl-python
building '_mysql' extension
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mysql.c -o build/temp.macosx-10.9-intel-2.7/_mysql.o -Wno-null-conversion -Os -g -fno-strict-aliasing -arch x86_64
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this …Run Code Online (Sandbox Code Playgroud) 请注意,这与名为generic makefile的其他问题不重复.
我已经遵循了有关通用makefile的其他问题的所有说明,这是我从中得出的代码:
CFLAGS = -c
CC = cc
SOURCES = $(wildcard *.cc)
OBJECTS = $(patsubst %.cc,%.o,%(SOURCES))
EXEC = run
all: build clean
build: $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXEC)
%.o: %.cc
$(CC) $(CFLAGS) $<
clean:
rm *.o
Run Code Online (Sandbox Code Playgroud)
但是,当我make使用test.cc我的目录中调用的文件执行时,它会给我一个followig错误:
cc -o run
cc: error: no input files
*** Error code 1
Stop.
make: stopped in /somewhere
Run Code Online (Sandbox Code Playgroud)
请注意我在FreeBSD上,make而cc命令是操作系统附带的命令.
我有使用${CC}变量进行编译器选择的 makefile:
${CC} $(CFLAGS) aaa.cpp -o aaa.o
Run Code Online (Sandbox Code Playgroud)
在 make ${CC} 期间带来 cc 编译器。${CC}但整体上没有定义makefile。这个变量怎么得呢cc?