首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么编译行是错误的,导致它无法找到头文件

为什么编译行是错误的,导致它无法找到头文件
EN

Stack Overflow用户
提问于 2021-06-22 23:28:30
回答 1查看 74关注 0票数 0

我有以下make文件:

代码语言:javascript
复制
######## Intel(R) SGX SDK Settings ########
SGX_SDK ?= /opt/intel/sgxsdk
SGX_MODE ?= SIM
SGX_ARCH ?= x64
UNTRUSTED_DIR=untrusted
M_BED=mbedtls_SGX-2.6.0    
########################### NOTE M_BED variable

ifeq ($(shell getconf LONG_BIT), 32)
    SGX_ARCH := x86
else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32)
    SGX_ARCH := x86
endif

ifeq ($(SGX_ARCH), x86)
    SGX_COMMON_CFLAGS := -m32
    SGX_LIBRARY_PATH := $(SGX_SDK)/lib
    SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign
    SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r
else
    SGX_COMMON_CFLAGS := -m64
    SGX_LIBRARY_PATH := $(SGX_SDK)/lib64
    SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign
    SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r
endif

ifeq ($(SGX_DEBUG), 1)
ifeq ($(SGX_PRERELEASE), 1)
$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!)
endif
endif

ifeq ($(SGX_DEBUG), 1)
        SGX_COMMON_CFLAGS += -O0 -g
else
        SGX_COMMON_CFLAGS += -O2
endif

######## App Settings ########

ifneq ($(SGX_MODE), HW)
    Urts_Library_Name := sgx_urts_sim
else
    Urts_Library_Name := sgx_urts
endif

# App_Cpp_Files := App/App.cpp $(wildcard App/Edger8rSyntax/*.cpp) $(wildcard App/TrustedLibrary/*.cpp)
App_Cpp_Files := $(UNTRUSTED_DIR)/m_server.cpp $(UNTRUSTED_DIR)/Utils.cpp \
    $(UNTRUSTED_DIR)/manager.cpp $(UNTRUSTED_DIR)/linear_regression.cpp \
    $(UNTRUSTED_DIR)/fileUtility.cpp $(UNTRUSTED_DIR)/dbHandler.cpp \
    $(UNTRUSTED_DIR)/naive_bayes.cpp
    
App_C_Files := $(UNTRUSTED_DIR)/mbedtls_net.c $(UNTRUSTED_DIR)/mbedtls_error.c
App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include -I$(M_BED)/include -I/usr/include/mysql

########################### NOTE M_BED include path

App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths)

########################### NOTE here

# Three configuration modes - Debug, prerelease, release
#   Debug - Macro DEBUG enabled.
#   Prerelease - Macro NDEBUG and EDEBUG enabled.
#   Release - Macro NDEBUG enabled.
ifeq ($(SGX_DEBUG), 1)
        App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG
else ifeq ($(SGX_PRERELEASE), 1)
        App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG
else
        App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG
endif

App_Cpp_Flags := $(App_C_Flags) -std=c++11
App_Link_Flags := $(SGX_COMMON_CFLAGS) -L$(SGX_LIBRARY_PATH) -L$(M_BED)/lib -l$(Urts_Library_Name) -lmbedtls_SGX_u -lpthread -lmysqlclient



ifneq ($(SGX_MODE), HW)
    App_Link_Flags += -lsgx_uae_service_sim
else
    App_Link_Flags += -lsgx_uae_service
endif

App_Cpp_Objects := $(App_Cpp_Files:.cpp=.o)
App_C_Objects := $(App_C_Files:.c=.o)



ifeq ($(SGX_MODE), HW)
ifneq ($(SGX_DEBUG), 1)
ifneq ($(SGX_PRERELEASE), 1)
Build_Mode = HW_RELEASE
endif
endif
endif


.PHONY: all run

ifeq ($(Build_Mode), HW_RELEASE)
all: osn_server
    @echo "Build osn_server [$(Build_Mode)|$(SGX_ARCH)] success!"
    @echo
    @echo "*********************************************************************************************************************************************************"
    @echo "PLEASE NOTE: In this mode, please sign the enclave.so first using Two Step Sign mechanism before you run the app to launch and access the enclave."
    @echo "*********************************************************************************************************************************************************"
    @echo


else
all: osn_server
endif

run: all
ifneq ($(Build_Mode), HW_RELEASE)
    @$(CURDIR)/osn_server
    @echo "RUN  =>  osn_server [$(SGX_MODE)|$(SGX_ARCH), OK]"
endif

######## App Objects ########

$(UNTRUSTED_DIR)/enclave_u.c: $(SGX_EDGER8R) trusted/enclave.edl
    @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../trusted/enclave.edl --search-path ../trusted --search-path $(SGX_SDK)/include
    @echo "GEN  =>  $@"

$(UNTRUSTED_DIR)/enclave_u.o: $(UNTRUSTED_DIR)/enclave_u.c
    @$(CC) $(App_C_Flags) -c $< -o $@
    @echo "CC   <=  $<"


$(UNTRUSTED_DIR)/%.o: $(UNTRUSTED_DIR)/%.cpp
    @$(CXX) $(App_Cpp_Flags) -c $< -o $@
    @echo "CXX  <=  $<"

########################### NOTE above

osn_server: $(UNTRUSTED_DIR)/enclave_u.o $(App_Cpp_Objects) $(App_C_Objects)
    @$(CXX) $^ -o $@ $(App_Link_Flags)
    @echo "LINK =>  $@"



.PHONY: clean

clean:
    @rm -f osn_server  $(App_Cpp_Objects) $(UNTRUSTED_DIR)/enclave_u.* $(App_C_Objects)

我的目录结构如下所示

代码语言:javascript
复制
├── common
│   ├── base64.h
│   ├── ml_struct.h
│   ├── network_ra.h
│   ├── remote_attestation_result.h
│   └── ssl_context.h
├── Makefile
├── mbedtls_SGX-2.6.0
│   ├── include
│   │   └── mbedtls
│   │       ├── aes.h
│   │       ├── aesni.h
│   │       ├── arc4.h
│   │       ├── asn1.h
│   │       ├── asn1write.h
│   │       ├── base64.h
│   │       ├── bignum.h
│   │       ├── blowfish.h
│   │       ├── bn_mul.h
│   │       ├── camellia.h
│   │       ├── ccm.h
│   │       ├── certs.h
│   │       ├── check_config.h
│   │       ├── cipher.h
│   │       ├── cipher_internal.h
│   │       ├── cmac.h
│   │       ├── compat-1.3.h
│   │       ├── config.h
│   │       ├── ctr_drbg.h
│   │       ├── debug.h
│   │       ├── des.h
│   │       ├── dhm.h
│   │       ├── ecdh.h
│   │       ├── ecdsa.h
│   │       ├── ecjpake.h
│   │       ├── ecp.h
│   │       ├── ecp_internal.h
│   │       ├── entropy.h
│   │       ├── entropy_poll.h
│   │       ├── error.h
│   │       ├── gcm.h
│   │       ├── glue.h
│   │       ├── havege.h
│   │       ├── hmac_drbg.h
│   │       ├── md2.h
│   │       ├── md4.h
│   │       ├── md5.h
│   │       ├── md.h
│   │       ├── md_internal.h
│   │       ├── memory_buffer_alloc.h
│   │       ├── net.h
│   │       ├── net_sockets.h
│   │       ├── oid.h
│   │       ├── padlock.h
│   │       ├── pem.h
│   │       ├── pkcs11.h
│   │       ├── pkcs12.h
│   │       ├── pkcs5.h
│   │       ├── pk.h
│   │       ├── pk_internal.h
│   │       ├── platform.h
│   │       ├── platform_time.h
│   │       ├── ripemd160.h
│   │       ├── rsa.h
│   │       ├── sha1.h
│   │       ├── sha256.h
│   │       ├── sha512.h
│   │       ├── ssl_cache.h
│   │       ├── ssl_ciphersuites.h
│   │       ├── ssl_cookie.h
│   │       ├── ssl.h
│   │       ├── ssl_internal.h
│   │       ├── ssl_ticket.h
│   │       ├── threading.h
│   │       ├── timing.h
│   │       ├── version.h
│   │       ├── x509_crl.h
│   │       ├── x509_crt.h
│   │       ├── x509_csr.h
│   │       ├── x509.h
│   │       └── xtea.h
│   └── lib
│       ├── libmbedtls_SGX_t.a
│       ├── libmbedtls_SGX_u.a
│       └── mbedtls_SGX.edl
├── metadata.txt
├── sgx_t.mk
├── sgx_u.mk
├── third_party
│   ├── rapidjson
│   │   ├── allocators.h
│   │   ├── document.h
│   │   ├── encodedstream.h
│   │   ├── encodings.h
│   │   ├── error
│   │   │   ├── en.h
│   │   │   └── error.h
│   │   ├── filereadstream.h
│   │   ├── filewritestream.h
│   │   ├── fwd.h
│   │   ├── internal
│   │   │   ├── biginteger.h
│   │   │   ├── diyfp.h
│   │   │   ├── dtoa.h
│   │   │   ├── ieee754.h
│   │   │   ├── itoa.h
│   │   │   ├── meta.h
│   │   │   ├── pow10.h
│   │   │   ├── regex.h
│   │   │   ├── stack.h
│   │   │   ├── strfunc.h
│   │   │   ├── strtod.h
│   │   │   └── swap.h
│   │   ├── istreamwrapper.h
│   │   ├── memorybuffer.h
│   │   ├── memorystream.h
│   │   ├── msinttypes
│   │   │   ├── inttypes.h
│   │   │   └── stdint.h
│   │   ├── ostreamwrapper.h
│   │   ├── pointer.h
│   │   ├── prettywriter.h
│   │   ├── rapidjson.h
│   │   ├── reader.h
│   │   ├── schema.h
│   │   ├── stream.h
│   │   ├── stringbuffer.h
│   │   └── writer.h
│   └── single_include
│       └── nlohmann
│           └── json.hpp
├── trusted
│   ├── ca_bundle.h
│   ├── check.cpp
│   ├── dtree.h
│   ├── ecalls.cpp
│   ├── e_engine.cpp
│   ├── e_engine.h
│   ├── encdec.cpp
│   ├── encdec.h
│   ├── enc.h
│   ├── enclave.config.xml
│   ├── enclave.edl
│   ├── enclave.h
│   ├── enclave.lds
│   ├── enclave_private.pem
│   ├── Log.c
│   ├── Log.h
│   ├── pprint.c
│   ├── pprint.h
│   ├── sealunseal.cpp
│   ├── sealunseal.h
│   ├── ssl_conn_hdlr.cpp
│   ├── ssl_conn_hdlr.h
│   └── trusted_LR.h
└── untrusted
    ├── dbHandler.cpp
    ├── dbHandler.h
    ├── dbHandler.o
    ├── enclave_u.c
    ├── enclave_u.h
    ├── enclave_u.o
    ├── fileUtility.cpp
    ├── fileUtility.h
    ├── fileUtility.o
    ├── globals.h
    ├── linear_regression.cpp
    ├── linear_regression.h
    ├── linear_regression.o
    ├── manager.cpp
    ├── manager.o
    ├── mbedtls_error.c
    ├── mbedtls_net.c
    ├── m_server.cpp
    ├── m_server.o
    ├── naive_bayes.cpp
    ├── naive_bayes.h
    ├── naive_bayes.o
    ├── sample_messages.h
    ├── Utils.cpp
    ├── Utils.h
    └── Utils.o

当我尝试构建它时,会失败,并显示以下错误:

代码语言:javascript
复制
make[1]: Entering directory '/home/intel/thesis/code/osn_server/sgx/enclave_enclave'
cc    -c -o untrusted/mbedtls_net.o untrusted/mbedtls_net.c
untrusted/mbedtls_net.c:24:25: fatal error: mbedtls/net.h: No such file or directory

我不知道为什么mbedtls/net.h文件没有找到,尽管它存在。任何解决方案或我如何尝试您的故障排除。

EN

回答 1

Stack Overflow用户

发布于 2021-06-22 15:45:27

将.c文件编译为.o文件的内置规则使用$(CFLAGS),而不是$(App_C_Flags)

有没有可能这个规则

代码语言:javascript
复制
$(UNTRUSTED_DIR)/enclave_u.o: $(UNTRUSTED_DIR)/enclave_u.c

实际上应该是这样概括的:

代码语言:javascript
复制
$(UNTRUSTED_DIR)/%.o: $(UNTRUSTED_DIR)/%.c
    @$(CC) $(App_C_Flags) -c $< -o $@
    @echo "CC   <=  $<"

这将使其适用于untrusted目录中的所有文件。或者,您可以设置CFLAGS=$(App_C_Flags)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68086474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档