Function, can't find file

So I'm making a function to replace a module in a project you guys helped me with. My code is below, but when I try to compile it I get this;

"/usr/bin/ld: cannot find -lab06
collect2: error: ld returned 1 exit status"

What am I missing here?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  // We are prompting the user to input a char, and
// an integer which will be the number of times the
// char repeats.

#include <iostream>
#include <iomanip>

using namespace std;

void StarRepeat(int n, char c) {
  if (n > 0){
    int counter =0;
    while(counter < n-1) {
       cout << c << ' ';
       counter++;
    }
  cout << c;

  }

   cout << endl;

  return;
}

int main(){

  int n {0};
  char c;

  cout << "Character:" << endl;
  cin >> c;
  cout << "Repeat:" << endl;
  cin >> n;

  StarRepeat(n,c );

  return 0;
The code itself is fine. It looks like you're trying to pass "-lab06" as an argument to your compiler (presumably GCC), which probably isn't what you want. Check what you're passing as command-line arguments when compiling/linking.
Last edited on
[d836244a@cslab103 Lab05]$ ls
lab05 lab05.cpp lab06.cpp
[d836244a@cslab103 Lab05]$ c++ lab06.cpp -lab06
/usr/bin/ld: cannot find -lab06
collect2: error: ld returned 1 exit status
[d836244a@cslab103 Lab05]$

This is exactly what I'm doing.
I'm pretty sure the flag you wanted instead of
-lab06
is
-o lab06


-l makes the linker look for a library of the attached name and link it in.

-Albatross
Last edited on
Topic archived. No new replies allowed.