码迷,mamicode.com
首页 > 移动开发 > 详细

android编译surface c++程序时,报错缺少.o文件

时间:2017-07-01 21:44:23      阅读:436      评论:0      收藏:0      [点我收藏+]

标签:demo   cli   后缀   .cpp   代码   sha   thread   read   pac   

近期在研究Android的surface系统,写了个小demo,编译的时候。一直报错,说是缺少.o文件,可是看代码一直没问题。后来发现原来是在window下编写的,然后在linux编译的时候,后缀多了^M。所以导致编译只是。

事实上提示类似的错误。肯定是代码那块地方出现了类似的错误。不知道的,查起来能累死,知道的非常快的就能知道怎么查。

顺便把源代码贴写。

testsurface.cpp

#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>


#include <cutils/memory.h>
#include<native_window.h>


#include <utils/Log.h>


#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>


#include <ui/GraphicBuffer.h>
#include <gui/Surface.h>
#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <cutils/properties.h>


#include <ui/DisplayInfo.h>
using namespace android;
int main(int argv,char *argc[])
{
    sp<ProcessState> proc(ProcessState::self());
    ProcessState::self()->startThreadPool();


    sp<SurfaceComposerClient> client = new SurfaceComposerClient();
    sp<SurfaceControl> surfaceControl = client->createSurface(String8("testsurface"),240, 160, PIXEL_FORMAT_RGBX_8888, 0);
    DisplayInfo dinfo;
    sp<IBinder> display = SurfaceComposerClient::getBuiltInDisplay(
            ISurfaceComposer::eDisplayIdMain);
    SurfaceComposerClient::getDisplayInfo(display, &dinfo);
    uint32_t dispw = dinfo.w;
    uint32_t disph = dinfo.h;


    /* create backgound surface */
    sp<SurfaceControl> bg_surfaceControl = client->createSurface(
            String8("test-bg-surface"), dispw, disph, PIXEL_FORMAT_RGBX_8888);


    sp<Surface> bg_surface = bg_surfaceControl->getSurface();

 /* set background layer z-order */
    SurfaceComposerClient::openGlobalTransaction();
    bg_surfaceControl->setLayer(200000);
    SurfaceComposerClient::closeGlobalTransaction();


    /* clear background layer black */
    ANativeWindow_Buffer outBuffer;


    bg_surface->lock(&outBuffer, NULL);
    ssize_t bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
    android_memset32((uint32_t*)outBuffer.bits, 0xFF000000, bpr * outBuffer.height);
    bg_surface->unlockAndPost();
    sleep(5);


    bg_surface->lock(&outBuffer, NULL);
     bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
    android_memset32((uint32_t*)outBuffer.bits, 0xF800, bpr * outBuffer.height);
    bg_surface->unlockAndPost();
    sleep(5);


    bg_surface->lock(&outBuffer, NULL);
    bpr = outBuffer.stride * bytesPerPixel(outBuffer.format);
    android_memset32((uint32_t*)outBuffer.bits, 0x7e56, bpr * outBuffer.height);
    bg_surface->unlockAndPost();
    sleep(5);
   return 0;
}

Android.mk

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)


LOCAL_SRC_FILES:= testsurface.cpp


LOCAL_C_INCLUDES := external/skia/include/core \
                    frameworks/native/include/android


LOCAL_SHARED_LIBRARIES := libcutils \
    libutils \
    libbinder \
    libui \
    libgui \


LOCAL_MODULE:= testsurface


LOCAL_MODULE_TAGS := tests


include $(BUILD_EXECUTABLE)

android编译surface c++程序时,报错缺少.o文件

标签:demo   cli   后缀   .cpp   代码   sha   thread   read   pac   

原文地址:http://www.cnblogs.com/ljbguanli/p/7103416.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!