c - C编译器gcc给出链接器命令失败错误
问题描述
我正在尝试使用来自两个不同文件的两个函数。我将这三个文件放在同一个文件夹中。编译器对我链接到的这两个函数给出了错误。这是我正在运行的主文件。
#include <stdio.h>
#include <stdlib.h>
#include "max_pool.h"
#include "convolutional.h"
#include "matrix_to_array.h"
int main() {
image im = load_image("doge.jpg");
int* result;
int scale = 100;
int* input = arrayUpScaling(im, im.h, im.w, im.c, scale);
result = pool_max(im.h, im.w, im.c, input);
int h = im.h;
int w = im.w;
int c = im.c;
for (int k = 0; k < c; k++) {
for (int i = 0; i < h; i++ ) {
for (int j = 0; j < w; j++ ) {
int dst_index = j + w*i + w*h*k;
printf("result[%d][%d][%d]: %d ", i, j, k, result[dst_index]);
}
printf("\n");
}
}
return 0;
}
在这个文件中,调用了来自其他文件的两个函数。一个是load_image(),另一个是arrayUpScaling()
这是卷积.h
#ifndef CON_H
#define CON_H
#include "image_to_matrix.h"
int SIZE[3];
//This program is a multiplier which supports input to be 4/8/16 bits
//It consists of three parts, a multiplier, an adder and an acumulator
which
//support 16/18/20/22 bits. This program will return a 8 bits value
int* readImage(image im, int scale);
int* get_Data_From_Con(int h, int w, int c, int* up_scaled_input, int
filter_size, int filter[filter_size][filter_size], int stride, int scale);
void buildSize(int* SIZE, int h, int w, int c);
int** truncateArray(int h, int w, int filter_size, int** input, int col, int row);
int** addPadding(int h, int w, int input[h][w], int h_padding, int w_padding);
int** inputManagement(int h, int w, int filter_size, int input[h][w],
int filter[filter_size][filter_size], int stride,
int scale);
int multiplier(int first, int second, int bitwidth, int scale);
int accumulator(int previous, int product);
int mat(int size, int** input, int filter[size][size], int scale);
int* arrayUpScaling(image im, int h, int w, int c, int scale);
float** arrayDownScaling(int h, int w, int scale, int** input);
void freeIntArray(int rows, int** arr);
void freeDoubleArray(int rows, float** arr);
int relu(int input);
#endif
这是 max_pool.h
#ifndef MAXP_H
#define MAXP_H
int* pool_max(int h, int w, int c, int* data);
int selectMax(int h, int w, int filter_size, int input[h][w], int col, int row);
#endif
这是 image_to_matrix.h
#ifndef IMA_H
#define IMA_H
typedef struct{
int w,h,c;
float *data;
} image;
float get_pixel(image im, int x, int y, int c);
image make_image(int w, int h, int c);
image load_image(char *filename);
image make_empty_image(int w, int h, int c);
image load_image_stb(char *filename, int channels);
void free_image(image im);
#endif
下面显示错误
Undefined symbols for architecture x86_64:
"_arrayUpScaling", referenced from:
_main in max_pool-7ba8aa.o
"_load_image", referenced from:
_main in max_pool-7ba8aa.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
这是我正在使用的编译命令
gcc -Wall -std=c11 -g -o max max_pool.c
所有文件都在同一个文件夹中,为什么链接会成为问题?
解决方案
推荐阅读
- python - Gitlab-ci 不识别 python
- c# - 如何在 Windows 和 Linux 系统上使用 Avalonia 框架处理系统关闭事件?
- python - 使用 Python 类创建 Stripe 对象和处理错误的最佳方式
- python - 为什么我可以返回完整的查询结果,但不能返回指定的项目?
- flutter - SharedPref 带有旧数据
- hyperledger-fabric - Hyperledger Fabric 在 2 个或多个网络之间进行交叉通信
- reactjs - 如何在无限行模式下在 ag-grid 上选择一行
- r - 从列表中读取和连接文件
- python - 使用其他文本文件的一部分编写文本文件
- python - 有效负载的 Python 和 coapthon3 奇怪行为