链接错误链接Makefile中的静态库为extern

时间:2015-11-29 04:47:00

标签: c++ makefile static-libraries ps3

我正在尝试为Cell Broadband Engine(PS3)编写一个makefile,它将链接一个外部库。

Makefile如下:

PROJ=apple_sort_ppu
PCC=ppu-g++
CFLAGS=-Wall
LIBS= -lX11 -lspe2 -lpthread

objects = apple_sort_ppu.o lodepng.o ThreadPool.o SPUTask.o
#Imports is for linking the extern spu program library to SPUTask.o.     Currently not linking correctly
IMPORTS := spu/lib_process_spu_a.a  $(LIBS)
all: $(PROJ) 

apple_sort_ppu: $(objects)
    $(PCC) $(objects) -o $(LIBS)

apple_sort_ppu.o: apple_sort_ppu.cpp
    $(PCC) $(CFLAGS) -c apple_sort_ppu.cpp $(LIBS)

lodepng.o: lodepng.cpp lodepng.h
    $(PCC) $(CFLAGS) -c lodepng.cpp

SPUTask.o: SPUTask.cpp SPUTask.h $(IMPORTS) ThreadPool.o
    $(PCC) $(CFLAGS)  -c SPUTask.cpp

ThreadPool.o: ThreadPool.cpp ThreadPool.h
    $(PCC) $(CFLAGS) -c ThreadPool.cpp $(LIBS)

clean:
    rm $(objects) *.d

include $(CELL_TOP)/buildutils/make.footer

当我在这个文件上运行make时,我得到:

No rule to make spu/lib_process_spu_a.a, needed by SPUTask.o. STOP

我已确认该库存在于正确的目录中。我对Makefile的体验非常有限,所以我真的不明白这里发生了什么。

导致makefile中出现问题的文件是SPUTask.h,标题代码为:

#pragma once
#include "ThreadPool.h"
#include <libspe2.h>

extern spe_program_handle_t process_spu_a;//Program handle

class SPUTask : public Task
{
public:
    SPUTask(int i_id = 0);
    virtual ~SPUTask(){;}   
    virtual void execute();
    virtual bool hasReturnData(){return false;}
    virtual int getTaskID(){return m_id;}
    void setData(unsigned char* pData, int pSize);
    void setContext(spe_context_ptr_t pContext){mContext = pContext;}
private:
    unsigned char* mData __attribute__((aligned(128)));
    int m_id;
    int mDataSize;
    spe_context_ptr_t mContext;
};

process_spu_a已经编译到/ spu子目录中的lib_process_spu_a.a。

非常感谢任何帮助。

0 个答案:

没有答案