Trouble Compiling gtest with Makefile

I want to flash the code I wrote with gtest to an NXP processor with an ARM Cortex-M0 core.

In the end, I want to write bsp_uart on top of the SDK I have and read the LOG.

My primary goal is to run the code and SDK on QEMU. For this reason, I prepared a Makefile to generate an ELF file output and added the toolchain. However, I am getting the following error. What could be the cause of this error?

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>googletest/googletest/include/gtest/internal/gtest-type-util.h:75: Error: bad instruction `size_t pos=0'
</code>
<code>googletest/googletest/include/gtest/internal/gtest-type-util.h:75: Error: bad instruction `size_t pos=0' </code>
googletest/googletest/include/gtest/internal/gtest-type-util.h:75: Error: bad instruction `size_t pos=0'

I receive hundreds of messages like the error above, I only wrote one of them.

There is a gtest version 1.8.1 with an example Makefile, do I have to use that one?

Before this error, I was getting the following error:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>undefined reference to `testing::Test::~Test
</code>
<code>undefined reference to `testing::Test::~Test </code>
undefined reference to `testing::Test::~Test

For this, it was necessary to link gtest_main and gtest. I tried to link them myself, but afterwards, I encountered the error mentioned above.

However, when I run the same code with CMake, I don’t get an error.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>target_link_libraries(test_foo
gtest_main
gmock
pthread
lib)
</code>
<code>target_link_libraries(test_foo gtest_main gmock pthread lib) </code>
target_link_libraries(test_foo
gtest_main
gmock
pthread
lib)

There is no issue when I write it. I can’t share the entire Makefile right now, but I can say that I encountered the first error I mentioned when I did it as shown below

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>GTEST_DIR=googletest/googletest
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h
$(GTEST_DIR)/include/gtest/internal/*.h
SOURCE_DIR+=$(GTEST_HEADERS)
</code>
<code>GTEST_DIR=googletest/googletest GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h $(GTEST_DIR)/include/gtest/internal/*.h SOURCE_DIR+=$(GTEST_HEADERS) </code>
GTEST_DIR=googletest/googletest
GTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h 
                $(GTEST_DIR)/include/gtest/internal/*.h
SOURCE_DIR+=$(GTEST_HEADERS)

The second error (the undefined reference) I received is from the following Makefile;

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>GTEST_BASEDIR_SDK:=googletest/googletest/include/
GTEST_BASEDIR_SRC_SDK:=googletest/googletest/src/
SOURCE_DIR+=$(GTEST_BASEDIR_SDK)
SOURCE_DIR+=$(GTEST_BASEDIR_SRC_SDK)
</code>
<code>GTEST_BASEDIR_SDK:=googletest/googletest/include/ GTEST_BASEDIR_SRC_SDK:=googletest/googletest/src/ SOURCE_DIR+=$(GTEST_BASEDIR_SDK) SOURCE_DIR+=$(GTEST_BASEDIR_SRC_SDK) </code>
GTEST_BASEDIR_SDK:=googletest/googletest/include/
GTEST_BASEDIR_SRC_SDK:=googletest/googletest/src/
SOURCE_DIR+=$(GTEST_BASEDIR_SDK)
SOURCE_DIR+=$(GTEST_BASEDIR_SRC_SDK)

The includes of my test code are as follows;

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>#include "gtest/gtest.h"
#include <iostream>
extern "C" {
#include "../../lib/assembly/cmsis_gcc.h"
#include "bsp_i2c.h"
}
#include "fff.h"
</code>
<code>#include "gtest/gtest.h" #include <iostream> extern "C" { #include "../../lib/assembly/cmsis_gcc.h" #include "bsp_i2c.h" } #include "fff.h" </code>
#include "gtest/gtest.h"
#include <iostream>
extern "C" {
#include "../../lib/assembly/cmsis_gcc.h"
#include "bsp_i2c.h"
}
#include "fff.h"

My goal is to compile the test code written with gtest alongside my source code, then run the generated ELF file on QEMU. Afterward, I will flash this file onto the target using JLink.

Do you have any suggestions or is anyone else experiencing this issue?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật