DavidHuangYT 2022-02-21 22:28 采纳率: 100%
浏览 773
已结题

C-free 4.0标准版编译报错:[Error] g++.exe: cannot specify -o with -c or -S and multiple compilations

问题遇到的现象和发生背景

写题时,Dev-C++突然坏了,于是我换成了C-free,代码如下:

问题相关代码,请勿粘贴截图
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
const int N=1e6+5;
//put your deta here
int a[N];
int twice(int a[],int l,int r,int x){
    while(l<r){
        int m=(l+r)/2;
        if(a[m]==x){
            return m;
        }
        else if(a[m]>x){
            r=m;
        }
        else{
            l=m+1;
        }
    }
    return -1;
}
int main() {
    //put your code here
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    while(m--){
        int x;
        cin>>x;
        cout<<twice(a,1,n+1,x)<<"\n";
    }
    return 0;
}

运行结果及报错内容

报错:
--------------------配置: mingw2.95 - CUI Debug, 编译器类型: MinGW (Old)--------------------

正在编译 E:\Program Files (x86)\C-Free Standard\temp\未命名3.cpp
[Error] g++.exe: cannot specify -o with -c or -S and multiple compilations

编译中止 E:\Program Files (x86)\C-Free Standard\temp\未命名3.cpp: 1 个错误, 0 个警告

我的解答思路和尝试过的方法

代码能运行,所以我觉得是编译器的问题

我想要达到的结果

有没有哪个人能看出来错啊!

  • 写回答

1条回答 默认 最新

  • _GX_ 2022-02-21 22:39
    关注

    编译器没有问题,是你用的不对。错误提示说的很明确了,如果-o与-c选项同时出现时,只能一个一个文件编译

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 7月21日
  • 已采纳回答 7月13日
  • 创建了问题 2月21日

悬赏问题

  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥15 小红薯封设备能解决的来
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'
  • ¥15 vue+element项目中多tag时,切换Tab时iframe套第三方html页面需要实现不刷新
  • ¥50 深度强化学习解决能源调度问题