大家.我对golang的构建有问题.
细节:
我有一个名为"12"的文件夹,并创建一个名为12_test.go的go源文件.代码如下:
package main
import "fmt"
func main() {
fmt.Println("Hello world")
}
Run Code Online (Sandbox Code Playgroud)
然后输入"go build 12_test.go".出了点问题:
"go build command-line-arguments: no buildable Go source files in D:\12"
Run Code Online (Sandbox Code Playgroud)
那么,有人可以告诉我为什么吗?感谢并为我可怜的英语道歉.
我有一个.cpp档案:htonstest.cpp.我g++用来编译它:
$ g++ -o test htonstest.cpp
Run Code Online (Sandbox Code Playgroud)
它工作,程序./test也有效.
但是,当我使用automake编译它时,有一个编译错误:
htonstest.cpp: In function ‘int main()’:
htonstest.cpp:6: error?expected id-expression before ‘(’ token.
Run Code Online (Sandbox Code Playgroud)
我的操作系统是CentOS,gcc的版本是4.1.2 20080704,autoconf的版本是2.59,automake的版本是1.9.6.
重现:
$ aclocal
$ autoheader
$ autoconf
$ automake -a
$ ./configure
$ make
Run Code Online (Sandbox Code Playgroud)
ntohstest.cpp:
#include <netinet/in.h>
#include <iostream>
int main()
{
short a = ::ntohs(3);
std::cout << a << std::endl;
std::cin.get();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
configure.ac:
AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([htonstest.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([foreign])
# Checks for programs.
AC_PROG_CXX
# Checks for …Run Code Online (Sandbox Code Playgroud)