Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

C++ undefined reference to, error when compiling with g++

$
0
0

I am making an implementation of ChaCha20. When compiling my code using g++ I get the "undefined reference to" error.

My main.cpp file.

#include <iostream>#include "chacha.h"Chacha20 cipher;int main() {        uint32_t test_vector[4] = {0x11111111, 0x01020304, 0x9b8d6f43, 0x01234567};        cipher.quarter_round(test_vector);        return 0;}

My chacha.h file.

#include <cstdint>class Chacha20 {        public:                void quarter_round(uint32_t *arr);        private:                uint32_t key[4];                uint32_t chacha_state[16];};

My chacha.cpp file.

#include <cstdint>class Chacha20 {        public:                void quarter_round(uint32_t *arr) {                }        private:                uint32_t key[4];                uint32_t chacha_state[16];};

Running g++ main.cpp chacha.cpp chacha.h returns the following error.

/usr/bin/ld: /tmp/ccoCsegN.o: in function `main':main.cpp:(.text+0x36): undefined reference to `Chacha20::quarter_round(unsigned int*)'collect2: error: ld returned 1 exit statuszsh: exit 1     g++ main.cpp chacha.cpp chacha.h

Viewing all articles
Browse latest Browse all 11661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>