G ++: unable to link to main executable

I am developing an application that uses statistical attacks to crack wep keys.

When I compile with my makefile (above), I get this error:

ld: cannot be associated with the main executable file 'execStatAttack' for x86_64 architecture

clang: error: the linker command worked with exit code 1 (use -v to see invocation) make: * [statAttack] Error 1

My project contains these files:

  • statAttack.cpp: contains the main function, uses the files above

  • rc4.h + rc4.cpp: using this function

#include <iostream>
#include <stdlib.h>
#include <stdio.h
#include <vector

#ifndef RC4
#define RC4

using namespace std
int* rc4(int);
int random_byte();
vector<int> cipher_mess_seq (long, int);

#endif
  • bias.h + bias.cpp:
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <utility>
#include <fstream>
#include <vector>
#include <string>

#ifndef BIAIS
#define BIAIS

using namespace std;

typedef pair<int,double> IntegerDoublePair;
vector<IntegerDoublePair> get_bias (string, int);
int compareTo (double, double);
vector<IntegerDoublePair> get_all_biases(string);

#endif
  • and makefile:
CC = g++
CFLAGS = -Wall -g
LDFLAGS = -lm 
EXEC_NAME_NAIVE = execNaiveAttack
EXEC_NAME_STATALGO = execStatAttack
OBJ_FILES_NAIVE = naiveAttack.o biais.o rc4.o
OBJ_FILES_STATALGO = statAttack.o biais.o rc4.o

naiveAttack : $(EXEC_NAME_NAIVE)

statAttack : $(EXEC_NAME_STATALGO)

$(EXEC_NAME_NAIVE) : $(OBJ_FILES_NAIVE)
   $(CC) $(OBJ_FILES_NAIVE) $(LDFLAGS) -o $(EXEC_NAME_NAIVE)

$(EXEC_NAME_STATALGO) : $(OBJ_FILES_STATALGO)
   $(CC) $(OBJ_FILES_STATALGO) $(LDFLAGS) -o $(EXEC_NAME_STATALGO)

%.o : %.cpp
   $(CC) $(CFLAGS) -o $@ -c $<

clean :
   rm -f $(OBJ_FILES_NAIVE) $(OBJ_FILES_STATALGO)

mrproper: clean
   rm -rf $(EXEC_NAME_NAIVE) $(EXEC_NAME_STATALGO)

this is my configuration (terminal):

==> g ++ --version

Configurable with: --prefix = / Applications / Xcode.app / Content / Developer / usr --with-gxx-include-dir = / usr / include / C ++ / 4.2.1

Apple LLVM 5.1 (clang-503.0.40) ( LLVM 3.4svn)

: x86_64-apple-darwin13.1.0

: posix

, , , .

.

+4
2

, -c , :

%.o: %.c
    $(CC) $(CFLAGS) -o $@ $^
Program: main.o
    $(CC) $(LDFLAGS) -o $@ $^

, , main.o , , , , , .

, , " ".

, , , , .

, , -c , , .

%.o: %.c
    $(CC) $(CFLAGS) -c -o $@ $^
+3

( . . , ( ))

@Paul R :

, . #include <vector using namespace std - , .

@ ():

bias bias, biais .

OP ():

- , make :   naiveAttack : $(EXEC_NAME_NAIVE) statAttack : $(EXEC_NAME_STATALGO)  , , , make , .

0

Source: https://habr.com/ru/post/1536940/


All Articles