我正在尝试使用两个不同文件中的两个函数。我把这三个文件放在同一个文件夹中。 编译器在我链接的这两个函数上给出了错误。 这是我正在运行的主文件。
#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()
这是convolutional.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
所有文件都在同一个文件夹中,为什么链接会成为问题?