CC=g++
FLAGS=-L./lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc
all: ColorTransfer
ColorTransfer: main.o ColorTransfer.o
$(CC) $(FLAGS) main.o ColorTransfer.o -o ColorTransfer
main.o: main.cpp
$(CC) $(FLAGS) -c main.cpp -o main.o
ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
$(CC) $(FLAGS) -c ColorTransfer.cpp -o ColorTransfer.o
clean :
rm -rf main.o ColorTransfer.o
这是我的Makefile,库放在当前目录的lib目录下,但是链接的时候会找不到库???
g++ -L/usr/local/lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc main.o ColorTransfer.o
main.o: In function `showImg(std::string, cv::Mat, int)':
main.cpp:(.text+0x21): undefined reference to `cv::namedWindow(std::string const&, int)'
main.cpp:(.text+0x34): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
main.cpp:(.text+0x75): undefined reference to `cv::imshow(std::string const&, cv::_InputArray const&)'
main.cpp:(.text+0x9d): undefined reference to `cv::waitKey(int)'
main.o: In function `main':
12 个解决方案
#1
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
#2
g++ -L/usr/local/lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc main.o ColorTransfer.o
仅仅是找了/usr/local/lib目录下的lib。
仅仅是找了/usr/local/lib目录下的lib。
#3
还是不行。。
#4
不好意思,一开始输错了,已修改。请问哪里出错了?
#5
自己连接的自己生成库,把名字补全一个一个的写进去!
#6
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so ./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
是这个意思吗?还是不行。。
#7
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
#8
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
#9
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
CC=g++
CFLAGS += -I.
CFLAGS += -I./include
DFLAGS = -L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
all: ColorTransfer
ColorTransfer: main.o ColorTransfer.o
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
main.o: main.cpp
$(CC) $(CFLAGS) -c main.cpp -o main.o
ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
$(CC) $(CFLAGS) -c ColorTransfer.cpp -o ColorTransfer.o
clean :
rm -rf main.o ColorTransfer.o
成功!但是一定要写全路径吗?
#10
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
CC=g++
CFLAGS += -I.
CFLAGS += -I./include
DFLAGS += -L./lib/ -lopencv_core -lopencv_highgui -lopencv_imgproc
all: ColorTransfer
ColorTransfer: main.o ColorTransfer.o
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
main.o: main.cpp
$(CC) $(CFLAGS) -c main.cpp -o main.o
ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
$(CC) $(CFLAGS) -c ColorTransfer.cpp -o ColorTransfer.o
clean :
rm -rf main.o ColorTransfer.o
也是对的,为什么CFLAGS和DFLAGS要分开写呢?
#11
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
CC=g++
CFLAGS += -I.
CFLAGS += -I./include
DFLAGS += -L./lib/ -lopencv_core -lopencv_highgui -lopencv_imgproc
all: ColorTransfer
ColorTransfer: main.o ColorTransfer.o
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
main.o: main.cpp
$(CC) $(CFLAGS) -c main.cpp -o main.o
ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
$(CC) $(CFLAGS) -c ColorTransfer.cpp -o ColorTransfer.o
clean :
rm -rf main.o ColorTransfer.o
也是对的,为什么CFLAGS和DFLAGS要分开写呢?
引导的时候不一样吧!
#12
不明白啊 最后解释成执行语句的时候 还是写成一行
gcc main.o -c main.c -I./include -L./lib -lxxxlib -lxxxlib
为啥不能写一起呢
gcc main.o -c main.c -I./include -L./lib -lxxxlib -lxxxlib
为啥不能写一起呢
#1
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
#2
g++ -L/usr/local/lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc main.o ColorTransfer.o
仅仅是找了/usr/local/lib目录下的lib。
仅仅是找了/usr/local/lib目录下的lib。
#3
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
#4
g++ -L/usr/local/lib -I./include -I. -lopencv_core -lopencv_highgui -lopencv_imgproc main.o ColorTransfer.o
仅仅是找了/usr/local/lib目录下的lib。
不好意思,一开始输错了,已修改。请问哪里出错了?
#5
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
#6
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so ./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
是这个意思吗?还是不行。。
#7
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
#8
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
#9
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
CC=g++
CFLAGS += -I.
CFLAGS += -I./include
DFLAGS = -L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
all: ColorTransfer
ColorTransfer: main.o ColorTransfer.o
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
main.o: main.cpp
$(CC) $(CFLAGS) -c main.cpp -o main.o
ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
$(CC) $(CFLAGS) -c ColorTransfer.cpp -o ColorTransfer.o
clean :
rm -rf main.o ColorTransfer.o
成功!但是一定要写全路径吗?
#10
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
CC=g++
CFLAGS += -I.
CFLAGS += -I./include
DFLAGS += -L./lib/ -lopencv_core -lopencv_highgui -lopencv_imgproc
all: ColorTransfer
ColorTransfer: main.o ColorTransfer.o
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
main.o: main.cpp
$(CC) $(CFLAGS) -c main.cpp -o main.o
ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
$(CC) $(CFLAGS) -c ColorTransfer.cpp -o ColorTransfer.o
clean :
rm -rf main.o ColorTransfer.o
也是对的,为什么CFLAGS和DFLAGS要分开写呢?
#11
CFLAGS += -I
CFLAGS += -I./include
DFLAGS=-L./libxx.a -lopencv_core -lopencv_highgui -lopencv_imgproc
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
// lib自己的库补全试试
还是不行。。
自己连接的自己生成库,把名字补全一个一个的写进去!
CC=g++
FLAGS += -I
FLAGS += -I./include
FLAGS=-L./lib/libopencv_core.so -L./lib/libopencv_highgui.so -L./lib/libopencv_imgproc.so -lopencv_core -lopencv_highgui -lopencv_imgproc
刚才少打了个L,但还是不行。。
再好好看看!库文件和头文件引导的时候不一样的! 一个是CFLAGS 一个DFLAGS
CC=g++
CFLAGS += -I.
CFLAGS += -I./include
DFLAGS += -L./lib/ -lopencv_core -lopencv_highgui -lopencv_imgproc
all: ColorTransfer
ColorTransfer: main.o ColorTransfer.o
$(CC) $(CFLAGS) main.o ColorTransfer.o -o ColorTransfer $(DFLAGS)
main.o: main.cpp
$(CC) $(CFLAGS) -c main.cpp -o main.o
ColorTransfer.o: ColorTransfer.cpp ColorTransfer.h
$(CC) $(CFLAGS) -c ColorTransfer.cpp -o ColorTransfer.o
clean :
rm -rf main.o ColorTransfer.o
也是对的,为什么CFLAGS和DFLAGS要分开写呢?
引导的时候不一样吧!
#12
不明白啊 最后解释成执行语句的时候 还是写成一行
gcc main.o -c main.c -I./include -L./lib -lxxxlib -lxxxlib
为啥不能写一起呢
gcc main.o -c main.c -I./include -L./lib -lxxxlib -lxxxlib
为啥不能写一起呢