Reputation: 2779
I am using go version go version "go1.14.4 linux/amd64" on ubuntu 18. This code wasn't written by me, but I believe it worked with a go version a few years older than my current one. When I try to build, I get this error. Any ideas what I need to do to fix?
go build *.go
go build command-line-arguments: invalid flag in #cgo LDFLAGS: - I/home/me/myProject/lib
Here's what I believe are the relevant bits of my go file:
package main
/*
#cgo LDFLAGS: -v -I${SRCDIR}/lib -lplaintext
#cgo CFLAGS: -I${SRCDIR}/include -I${SRCDIR}/lib
#include <stdlib.h>
#include "plaintext.h"
*/
import "C"
import (
"bufio"
"bytes"
"context"
"crypto/md5"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"log/syslog"
"net"
"net/http"
"os"
"os/signal"
"runtime"
"strings"
"strconv"
"sync"
"syscall"
"time"
"unsafe"
)
Upvotes: 0
Views: 4112
Reputation: 370
I believe you are trying to specify the search path for your library, so you should use -L
. -I
is used for the compiler include directories.
package main /*
#cgo LDFLAGS: -v -L${SRCDIR}/lib -lplaintext
#cgo CFLAGS: -I${SRCDIR}/include -I${SRCDIR}/lib
Upvotes: 1