Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
架构x86_64 MAC GCC的未定义符号_C_Xcode_Macos_Gcc - Fatal编程技术网

架构x86_64 MAC GCC的未定义符号

架构x86_64 MAC GCC的未定义符号,c,xcode,macos,gcc,C,Xcode,Macos,Gcc,因此,我尝试运行一些在windows中完美编译的c代码,并尝试使用Xcode和gcc编译器运行相同的代码,当我尝试编译时,我的代码中出现了这个错误 架构x86_64的未定义符号: “_stricmp”,引用自: _以cckZHFWV.o格式打印结果 ld:找不到架构x86_64的符号 collect2:ld返回了1个退出状态 无法理解为什么我会收到这个错误 下面是我试图编译的代码 #include <stdio.h> #include <stdlib.h> #includ

因此,我尝试运行一些在windows中完美编译的c代码,并尝试使用Xcode和gcc编译器运行相同的代码,当我尝试编译时,我的代码中出现了这个错误

架构x86_64的未定义符号: “_stricmp”,引用自: _以cckZHFWV.o格式打印结果 ld:找不到架构x86_64的符号 collect2:ld返回了1个退出状态

无法理解为什么我会收到这个错误

下面是我试图编译的代码

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "definitions.h"

//#define DEBUG 1

int main(int argc, char *argv[]) {
    FILE *config_file, *trace;
    unsigned int address, exec_info;
    char check, trash[25], op;
    int j, para;
    int i=0;

    //    char valid,dirty;
    //    unsigned int tag;
    //    next *tagstr;
    //    bptr tptr
    //    check if tptr is at head of list dont use bptr, dummy pointer

    if(argc >= 2)   
    config_file = fopen(argv[1],"r");    
    else 
    config_file = fopen("config0.txt","r");

    // Grabs desired cache parameters from the specified config files
    while(fscanf(config_file,"%s %d\n",trash,&para) == 2) {
    config[i] = para;
   i++;      
    }

    // Close the config file
    fclose(config_file);

    // Puts Cache parameters from config file in desired variables
    InitializeParameters();

    // Initializes the L1 and L2 caches into Linked List
    CacheInit();

    // Checks to see if file exists
    trace = fopen("I10.txt","r");
    if (!trace) {
    puts("I1.txt not found!");
    return 1;
    }

    while (fscanf(trace,"%c %x %x\n",&op,&address,&exec_info) == 3) {
    //printf("Op is %c, Address is %x, and exec is %x\n",op,address,exec_info); 
    switch(op) {
    case 'L': {
        load_count++;
        total++;
        //printf("Welcome to Load.\n");
        // do something
    }
    break;      
    case 'S': {
        store_count++;
        total++;
        //printf("Welcome to Store.\n");
        // do something here also
    }
    break;
    case 'B': {
        branch_count++;
        total++;
        //printf("Welcome to Branch.\n");
        // oh, don't forget this
    }
    break;      
    case 'C': {
        comp_count++;
        total++;
        //printf("Welcome to Computation.\n");        
        // Here, too 
    }
    break;
    }   // Handles incoming Operation data   
    }

    // Prints the Results of the Simulation
    PrintResults(argv[1]);
}

int InitializeParameters() {   
    L1_cache_size = config[0];
    L1_block_size = config[1];
    L1_assoc = config[2];
    L1_hit_time = config[3];
    L1_miss_time = config[4];
    L2_block_size = config[5];
    L2_cache_size = config[6];
    L2_assoc = config[7];
    L2_hit_time = config[8];
    L2_miss_time = config[9];
    L2_transfer_time = config[10];
    L2_bus_width = config[11];
    mem_sendaddr=config[12];
    mem_ready=config[13];
    mem_chunktime=config[14];
    mem_chunksize=config[15];    
}

int CacheInit() {
if(L1_assoc == 0){
L1_assoc = L1_cache_size / L1_block_size;
L1_sets = 1;
}
else
L1_sets = L1_cache_size / L1_block_size / L1_assoc;

if(L2_assoc == 0){
L2_assoc = L2_cache_size / L2_block_size;
L2_sets = 1;
}
else
L2_sets = L2_cache_size / L2_block_size / L2_assoc;    
}

int PrintResults(char *config_file) {
printf("--------------------------------------------------------\n");
printf("                   Simulation Results\n");
printf("--------------------------------------------------------\n");

// Trace File
printf("Trace File:\n");

// Cache Name
printf("Cache Type: ");
if (config_file == NULL)
printf("Direct Mapped\n\n");
if (stricmp("config0.txt",config_file) == 0)
printf("Direct Mapped\n\n");
if (stricmp("config1.txt",config_file) == 0)
printf("L1-2way\n\n");
if (stricmp("config2.txt",config_file) == 0)
printf("L2-2way\n\n");
if (stricmp("config3.txt",config_file) == 0)
printf("All-2way\n\n");
if (stricmp("config4.txt",config_file) == 0)
printf("2-4-way\n\n");
if (stricmp("config5.txt",config_file) == 0)
printf("L2-Big\n\n");
if (stricmp("config6.txt",config_file) == 0)
printf("All-FA\n\n");
if (stricmp("config7.txt",config_file) == 0)
printf("Direct Mapped 2 x Memory Chunksize\n\n");
if (stricmp("config8.txt",config_file) == 0)
printf("Direct Mapped 4 x Memory Chunksize%s\n\n");     

// Cache info
printf("Memory System:\n");
printf("  DCache Size = %Lu : Ways = %Lu : Block Size = %Lu\n",
   L1_cache_size, L1_assoc, L1_block_size);
printf("  ICache Size = %Lu : Ways = %Lu : Block Size = %lu\n",
   L1_cache_size, L1_assoc, L1_block_size);
printf("  L2-Cache Size = %Lu : Ways = %Lu : Block Size = %lu\n",
   L2_cache_size, L2_assoc, L2_block_size);
printf("  Memory Ready Time = %Lu : Chunksize = %Lu : Chunktime = %lu\n\n", mem_ready, mem_chunksize, mem_chunktime);

// Time
printf("Time:\n");
printf("  Execute Time = %Lu :", time);
printf(" Total Refs = %Lu\n", total + data_refs);
printf("  Inst Refs = %Lu :", total);
printf(" Data Refs = %Lu\n\n", data_refs);

// Number of Instructions
printf("Number of Instructions: [Percentage]\n");
printf("  Loads  (L) = %Lu",load_count);
printf(" [%.1f%%] :",100*load_count/ (double) total);
printf(" Stores (S) = %Lu",store_count);
printf(" [%.1f%%]\n",100*store_count/ (double) total);
printf("  Branch (B) = %Lu",branch_count);
printf(" [%.1f%%] :",100*branch_count/ (double) total);
printf(" Comp   (C) = %Lu",comp_count);
printf(" [%.1f%%]\n",100*comp_count/ (double) total);
printf("  Total  (T) = %Lu\n\n",total);

// Number of Cycles
printf("Cycles for Instructions: [Percentage]\n");
printf("  Loads  (L) = %Lu",load_cycle);
printf(" [%.1f%%] :",100*load_cycle/ (double) total_cycle);
printf(" Stores (S) = %Lu",store_cycle);
printf(" [%.1f%%]\n",100*store_cycle/ (double) total_cycle);
printf("  Branch (B) = %Lu",branch_cycle);
printf(" [%.1f%%] :",100*branch_cycle/ (double) total_cycle);
printf(" Comp   (C) = %Lu",comp_cycle);
printf(" [%.1f%%]\n",100*comp_cycle/ (double) total_cycle);
printf("  Total  (T) = %Lu\n\n",total_cycle);

// CPI
printf("Cycles Per Instructions:\n");
printf("  Loads      (L) = %.1f :", load_cycle/(double) load_count);
printf("  Stores (S) = %.1f%\n", store_cycle/(double) store_count);
printf("  Branch     (B) = %.1f :",
   branch_cycle/(double) branch_count);
printf("  Comp   (C) = %.1f\n", comp_cycle/ (double) comp_count);
printf("  Overall  (CPI) = %Lu\n\n", total_cycle/ (double) total);

// Real/Simulated Comparision
printf("Perfect to Simulation Comparision:\n");
printf("  Cycles for Processor w/Perfect Memory System %Lu\n",
   perfect_cycle);
printf("  Cycles for Processor w/Simulated Memory System %Lu\n",
   total_cycle);
printf("  Ratio of Simulated/Perfect Performance = %.6f\n\n",
   total_cycle/ (double) perfect_cycle );

// L1 ICache Hit/Miss
printf("Memory Level: L1 ICache\n");
printf("  Hit Count = %Lu : ", L1_I_hits);
printf("Miss Count = %Lu : ", L1_I_misses);
printf("Hit Count = %Lu\n", L1_I_hits+L1_I_misses);
printf("  Hit Rate = %.1f%% : Miss Rate = %.1f%%\n",
   100*L1_I_hits / (double) (L1_I_hits + L1_I_misses),
   100*L1_I_misses / (double) (L1_I_hits + L1_I_misses));
printf("  Kickouts = %Lu : ", L1_I_kickouts);
printf("Dirty Kickouts = %Lu : ", L1_I_kickouts_dirty);
printf("Transfers = %Lu\n\n", L1_I_transfers);

// L1 DCache Hit/Miss
printf("Memory Level: L1 DCache\n");
printf("  Hit Count = %Lu : ", L1_D_hits);
printf("Miss Count = %Lu : ", L1_D_misses);
printf("Hit Count = %Lu\n", L1_D_hits+L1_D_misses);
printf("  Hit Rate = %.1f%% : Miss Rate = %.1f%%\n",
   100*L1_D_hits / (double) (L1_D_hits + L1_D_misses),
   100*L1_D_misses / (double) (L1_D_hits + L1_D_misses));
printf("  Kickouts = %Lu : ", L1_D_kickouts);
printf("Dirty Kickouts = %Lu : ", L1_D_kickouts_dirty);
printf("Transfers = %Lu\n\n", L1_D_transfers);

// L2 Cache Hit/Miss
printf("Memory Level: L2\n");
printf("  Hit Count = %Lu : ", L2_hits);
printf("Miss Count = %Lu : ", L2_misses);
printf("Hit Count = %Lu\n", L2_hits+L2_misses);
printf("  Hit Rate = %.1f%% : Miss Rate = %.1f%%\n",
   100*L2_hits / (double) (L2_hits + L1_D_misses),
   100*L2_misses / (double) (L2_hits + L2_misses));
printf("  Kickouts = %Lu : ", L2_kickouts);
printf("Dirty Kickouts = %Lu : ", L2_kickouts_dirty);
printf("Transfers = %Lu\n\n", L2_transfers);

// Cost Analysis
printf("Cost:\n");
//L1 Cache Cost
L1_cost = (L1_cache_size / 4096) * 100 * (log2(L1_assoc) + 1);
cost += L1_cost*2;
printf("  L1 Cache Cost (ICache $%Lu) + (DCache $%Lu) = $%Lu\n",
   L1_cost, L1_cost, L1_cost*2);

// L2 Cache Cost
L2_cost = (L2_cache_size / (64*1024)) * 50 * (log2(L2_assoc) + 1);
cost += L2_cost;
printf("  L2 Cache Cost = $%Lu\n", L2_cost);

// Memory Cost
mem_cost = log2(100 / mem_ready) * 200 + 50;
mem_cost += (log2(mem_chunksize)-4)*100 + 25;
cost += mem_cost;
printf("  Memory Cost = $%Lu\n", mem_cost);

// Total Cost
printf("  Total Cost = $%Lu\n", cost);
}
#包括
#包括
#包括
#包括“定义.h”
//#定义调试1
int main(int argc,char*argv[]){
文件*配置文件,*跟踪;
无符号整数地址,执行信息;
字符检查,垃圾[25],op;
int j,第2段;
int i=0;
//字符有效,脏;
//无符号整数标记;
//下一步*tagstr;
//bptr tptr
//检查tptr是否在列表的最前面不要使用bptr,伪指针
如果(argc>=2)
config_file=fopen(argv[1],“r”);
其他的
config_file=fopen(“config0.txt”、“r”);
//从指定的配置文件中获取所需的缓存参数
而(fscanf(配置文件“%s%d\n”、垃圾桶和段落)==2){
配置[i]=第;
i++;
}
//关闭配置文件
fclose(配置文件);
//将配置文件中的缓存参数放入所需变量中
初始化参数();
//将L1和L2缓存初始化为链表
CacheInit();
//检查文件是否存在
trace=fopen(“I10.txt”,“r”);
如果(!跟踪){
puts(“未找到I1.txt!”);
返回1;
}
而(fscanf(跟踪,“%c%x%x\n”、&op、&address、&exec\u info)==3){
//printf(“Op是%c,地址是%x,exec是%x\n”,Op,地址,exec\u信息);
开关(op){
案例“L”:{
加载计数++;
总计++;
//printf(“欢迎加载。\n”);
//做点什么
}
打破
案例S:{
存储计数++;
总计++;
//printf(“欢迎光临商店。\n”);
//在这里也做点什么
}
打破
案例“B”:{
分支计数++;
总计++;
//printf(“欢迎来到分支机构。\n”);
//哦,别忘了这个
}
打破
案例“C”:{
comp_count++;
总计++;
//printf(“欢迎使用计算。\n”);
//这里也是
}
打破
}//处理传入的操作数据
}
//打印模拟结果
打印结果(argv[1]);
}
int InitializeParameters(){
L1_cache_size=config[0];
L1_block_size=config[1];
L1_assoc=配置[2];
L1_hit_time=config[3];
L1_miss_time=config[4];
L2_block_size=config[5];
二级缓存大小=配置[6];
L2_assoc=config[7];
L2_hit_time=config[8];
L2_miss_time=config[9];
L2_传输_时间=配置[10];
L2_总线_宽度=配置[11];
mem_sendaddr=config[12];
mem_ready=config[13];
mem_chunktime=config[14];
mem_chunksize=config[15];
}
int CacheInit(){
如果(L1_assoc==0){
L1_assoc=L1_缓存大小/L1_块大小;
L1_集=1;
}
其他的
L1_集=L1_缓存大小/L1_块大小/L1_关联;
如果(L2_assoc==0){
L2_assoc=L2_缓存大小/L2_块大小;
L2_集=1;
}
其他的
二级缓存集=二级缓存大小/二级块大小/二级关联;
}
int打印结果(字符*配置文件){
printf(“---------------------------------------------------------------\n”);
printf(“模拟结果”);
printf(“---------------------------------------------------------------\n”);
//跟踪文件
printf(“跟踪文件:\n”);
//缓存名称
printf(“缓存类型:”);
如果(配置文件==NULL)
printf(“直接映射\n\n”);
如果(stricmp(“config0.txt”,配置文件)==0)
printf(“直接映射\n\n”);
如果(stricmp(“config1.txt”,配置文件)==0)
printf(“L1-2way\n\n”);
如果(stricmp(“config2.txt”,配置文件)==0)
printf(“L2-2way\n\n”);
如果(stricmp(“config3.txt”,配置文件)==0)
printf(“全方位\n\n”);
如果(stricmp(“config4.txt”,配置文件)==0)
printf(“2-4-way\n\n”);
如果(stricmp(“config5.txt”,配置文件)==0)
printf(“L2大\n\n”);
如果(stricmp(“config6.txt”,配置文件)==0)
printf(“所有FA\n\n”);
如果(stricmp(“config7.txt”,配置文件)==0)
printf(“直接映射的2倍内存块大小\n\n”);
如果(stricmp(“config8.txt”,配置文件)==0)
printf(“直接映射的4倍内存块大小%s\n\n”);
//缓存信息
printf(“内存系统:\n”);
printf(“DCache Size=%Lu:Ways=%Lu:Block Size=%Lu\n”,
一级缓存大小、一级缓存关联、一级缓存块大小);
printf(“ICache大小=%Lu:Ways=%Lu:Block大小=%Lu\n”,
一级缓存大小、一级缓存关联、一级缓存块大小);
printf(“二级缓存大小=%Lu:Ways=%Lu:Block Size=%Lu\n”,
二级缓存大小、二级关联、二级块大小);
printf(“内存就绪时间=%Lu:Chunksize=%Lu:Chunktime=%Lu\n\n”,mem\u就绪,mem\u Chunksize,mem\u Chunktime);
//时间
printf(“时间:\n”);
printf(“执行时间=%Lu:,时间);
printf(“总引用=%Lu\n”,总+数据引用);
printf(“仪器参考=%Lu:”,总计);
printf(“数据引用=%Lu\n\n”,数据引用);
//指令数
printf(“指令数:[百分比]\n”);
printf(“负载(L)=%Lu”,负载计数);
printf(“[%.1f%]:”,100*装载计数/(双倍)总计);
printf(“存储=%Lu”,存储计数);
printf(“[%.1f%]\n”,总存储量为100*;
printf(“分支(B)=%Lu”,分支计数);
printf(“[.1f%]:”,100*分支机构计数/(双)总数);
printf(“成分(C)=%Lu”,成分计数);
printf(“[%.1f%]\n”,100*公司计数/(双倍)总计);
printf(“总计(T)=%Lu\n\n”,总计);
//循环次数
printf(“指令周期:[百分比]\n”);
printf(“加载(L)=%Lu”,加载循环);
printf(“[%.1f%]:”,100*负载循环/(双)总循环);
printf(“存储=%Lu”,存储周期);
printf(“[%.1f%%]\n”,100*存储周期/(双)总存储周期);
printf(“分支(B)=%Lu”,分支循环);
printf(“[%.1f%]:”,100*分支循环/(双)总循环);
printf(“Comp(C)=%Lu”,Comp_循环);
printf(“[%.1f%%]\n”,100*补偿周期/(双)总计